PUN errors when building for WEBGL

Options
Hi, I wanted to use PUN for my next game, but i'm facing problem when testing WEBGL build.
When I try to us the chat.

Here is my code:

#if UNITY_WEBGL
var protocol = ConnectionProtocol.WebSocketSecure;
#else
var protocol = ConnectionProtocol.Udp;
#endif
Chat = new ChatClient( Instance, protocol ) { ChatRegion = PhotonParams.Chat_DefaultRegion };
var auth = new ExitGames.Client.Photon.Chat.AuthenticationValues
{
UserId = "user_"+userID,
AuthType = ExitGames.Client.Photon.Chat.CustomAuthenticationType.None
};
Chat.Connect( PhotonParams.Chat_ID, PhotonParams.Chat_App_Version, auth );
Here is the webgl error when I test on browser:

exception thrown: ReferenceError: webSocketInstances is not defined,SocketCreate@blob:mygame:80:9
_SocketCreate@blob:mygame line 791 > eval:2438:10
_SocketCreate__wrapper@blob:mygame line 791 > eval:2603599:10
ftCall_ii@blob:mygame line 791 > eval:5777:10
invoke_ii@blob:mygame line 791 > eval:5764:11
_WebSocket_SocketCreate_m4170512625@blob:mygame line 791 > eval:1928583:8
asm._WebSocket_SocketCreate_m4170512625@blob:mygame line 791 > eval:2553211:10
ftCall_iiii@blob:mygame line 791 > eval:5930:10
invoke_iiii@blob:mygame line 791 > eval:5917:11
_WebSocket_Connect_m477610862@blob:mygame line 791 > eval:1890893:9
asm._WebSocket_Connect_m477610862@blob:mygame line 791 > eval:2413063:10
ftCall_vii@blob:mygame line 791 > eval:5012:10
invoke_vii@blob:mygame line 791 > eval:4999:4
_SocketWebTcp_Connect_m153352275@blob:mygame line 791 > eval:961895:15
asm._SocketWebTcp_Connect_m153352275@blob:mygame line 791 > eval:2482939:10
ftCall_iii@blob:mygame line 791 > eval:5420:10
invoke_iii@blob:mygame line 791 > eval:5407:11
_TPeer_Connect_m3592787906@blob:mygame line 791 > eval:699453:13
asm._TPeer_Connect_m3592787906@blob:mygame line 791 > eval:2484421:10
ftCall_iiiiii@blob:mygame line 791 > eval:4859:10
invoke_iiiiii@blob:mygame line 791 > eval:4846:11
_PhotonPeer_Connect_m1989910538@blob:mygame line 791 > eval:634636:16
asm._PhotonPeer_Connect_m1989910538@blob:mygame line 791 > eval:2562781:10
ftCall_iiiiii@blob:mygame line 791 > eval:4859:10
invoke_iiiiii@blob:mygame line 791 > eval:4846:11
_NetworkingPeer_ConnectToRegionMaster_m1876143704@blob:mygame line 791 > eval:1245694:13
asm._NetworkingPeer_ConnectToRegionMaster_m1876143704@blob:mygame line 791 > eval:2541787:10
ftCall_iiii@blob:mygame line 791 > eval:5930:10
invoke_iiii@blob:mygame line 791 > eval:5917:11
_PhotonNetwork_ConnectToRegion_m3403656020@blob:mygame line 791 > eval:616748:19
asm._PhotonNetwork_ConnectToRegion_m3403656020@blob:mygame line 791 > eval:2535283:10
ftCall_iiiii@blob:mygame line 791 > eval:4536:10
invoke_iiiii@blob:mygame line 791 > eval:4523:11
_MatchController_CreateMatch_m782372333@blob:mygame line 791 > eval:809866:9
asm._MatchController_CreateMatch_m782372333@blob:mygame line 791 > eval:2428369:10
ftCall_viiiii@blob:mygame line 791 > eval:4944:10
invoke_viiiii@blob:mygame line 791 > eval:4931:4
_Main_Start_m2091519880@blob:mygame line 791 > eval:673006:16
mftCall_vii@blob:mygame line 791 > eval:2370795:3
__Z31RuntimeInvoker_Void_t1841601450PFvvEPK10MethodInfoPvPS4_@blob:mygame line 791 > eval:2385723:2
asm.__Z31RuntimeInvoker_Void_t1841601450PFvvEPK10MethodInfoPvPS4_@blob:mygame line 791 > eval:2550007:10
ftCall_iiiii@blob:mygame line 791 > eval:4536:10
invoke_iiiii@blob:mygame line 791 > eval:4523:11
__ZN6il2cpp2vm7Runtime6InvokeEPK10MethodInfoPvPS5_PP15Il2CppException@blob:mygame line 791 > eval:2218862:8
_il2cpp_runtime_invoke@blob:mygame line 791 > eval:2351487:9
asm._il2cpp_runtime_invoke@blob:mygame line 791 > eval:2526601:10
_il2cpp_runtime_invoke@blob:mygame:11774:9
__Z23scripting_method_invoke18ScriptingMethodPtr18ScriptingObjectPtrR18ScriptingArgumentsP21ScriptingExceptionPtrb@blob:https://www.lagoon-dev.com/e0fafa1e-c22c-447e-92ed-a6d3582d365b:2696456:1
__ZN19ScriptingInvocation6InvokeEP21ScriptingExceptionPtrb@blob:https://www.lagoon-dev.com/e0fafa1e-c22c-447e-92ed-a6d3582d365b:2083494:1
__ZN13MonoBehaviour30InvokeMethodOrCoroutineCheckedE18ScriptingMethodPtr18ScriptingObjectPtrP21ScriptingExceptionPtr@blob:https://www.lagoon-dev.com/e0fafa1e-c22c-447e-92ed-a6d3582d365b:653805:1
__ZN13MonoBehaviour30InvokeMethodOrCoroutineCheckedE18ScriptingMethodPtr18ScriptingObjectPtr@blob:https://www.lagoon-dev.com/e0fafa1e-c22c-447e-92ed-a6d3582d365b:2012441:1
__ZN13MonoBehaviour16DelayedStartCallEP6ObjectPv@blob:https://www.lagoon-dev.com/e0fafa1e-c22c-447e-92ed-a6d3582d365b:2401536:1
mftCall_iii@blob:https://www.lagoon-dev.com/e0fafa1e-c22c-447e-92ed-a6d3582d365b:2849661:1
__ZN18DelayedCallManager6UpdateEi@blob:https://www.lagoon-dev.com/e0fafa1e-c22c-447e-92ed-a6d3582d365b:1122564:1
mftCall_vii@blob:https://www.lagoon-dev.com/e0fafa1e-c22c-447e-92ed-a6d3582d365b:2851775:1
__ZZ23InitPlayerLoopCallbacksvEN50EarlyUpdateScriptRunDelayedStartupFrameRegistrator7ForwardEv@blob:https://www.lagoon-dev.com/e0fafa1e-c22c-447e-92ed-a6d3582d365b:2739604:1
mftCall_v@blob:https://www.lagoon-dev.com/e0fafa1e-c22c-447e-92ed-a6d3582d365b:2888261:1
__Z10PlayerLoopv@blob:https://www.lagoon-dev.com/e0fafa1e-c22c-447e-92ed-a6d3582d365b:810410:1
__ZL8MainLoopv@blob:https://www.lagoon-dev.com/e0fafa1e-c22c-447e-92ed-a6d3582d365b:2135425:1
UnityLoader.f717af15d33bb54f54a277e3b7e022bb/asm.__ZL8MainLoopv@blob:mygame:209126:9
ftCall_v@blob:mygame:30838:9
browserIterationFunc@blob:mygame:11592:4
runIter@blob:mygame:10990:5
Browser_mainLoop_runner@blob:mygame:11630:3
Here is the debug return I got when I test in the editor:

[Chat] DebugReturn, Connect failed. SocketImplementationConfig is null for protocol WebSocketSecure: {(ConnectionProtocol)Udp=(MonoType)ExitGames.Client.Photon.SocketUdp, (ConnectionProtocol)Tcp=(MonoType)ExitGames.Client.Photon.SocketTcp}

Comments

  • I have the same webgl error when I try to call PhotonNetwork.ConnectToRegion():

    exception thrown: ReferenceError: webSocketInstances is not defined,SocketCreate@blob:mygame:80:9
    ...

    But it works well when I try on the editor.
  • benjamin_lagoon
    edited November 2017
    Options
    OK found the solution, I just added:

    var webSocketInstances = [];
    In my index.php file
    It seems that it's not exported with the WebSocket.jslib
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @benjamin_lagoon,

    Thank you for choosing Photon!

    I guess you are using Photon Chat (PhotonChatApi) from PUN, right?
    If that's the case, what PUN version do you use?
  • Yes I use PhotonChatApi from PUN, I downloaded PUN Free from unitystore yesterday and as I can see on the changelog, it seem to be the version v1.87. Is there an other place to see the version ?
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Yes, it should be the correct version which is the latest.
    To check PUN version you could get it from PhotonNetwork.versionPUN.