Photon Pun2 showing connection failed error in webgl build.

Hey guys we are using Photon PUN2 in one of our projects which needs to be deployed on web and it also happens to be our first project with PUN.

We integrated the PUN2 asset from asset store and embedded into our project and instantiated a ReadyPlayerMe avatar without making much changes in PhotonServerSettings from inspector. Everything works fine in Editor and Windows build but WebGL build shows below mentioned errors.

1.WebSocket connection to 'wss://ns.photonengine.io:19093/?libversion=4.1.6.11&sid=30&app=NameServer' failed: 

2.writeStringToMemory is deprecated and should not be called! Use stringToUTF8() instead!

3.BuildSmall.framework.js:1791 Exiting receive thread. Server: wss://ns.photonengine.io:19093:0 Error: Abnormal disconnection.

PUN2 v2.40(Latest)

Editor v2021.3.5f1


Best Answer

  • Tobias
    Tobias admin
    Answer ✓

    If you use PUN 2, you only have to enter your AppId in the PhotonServerSettings, switch the build target to WebGL and build. Nothing else needs to change. A WebGL build will automatically use the right connection type.

    I would test this: Create a new, empty project, import PUN 2 and check the version number shown in the PhotonServerSettings inspector. Insert the AppId and build one of our demos for WebGL (no changes by you).

    If this doesn't work on your machine via build and run, try another machine and or another network (the problem is not on the server side or such).

    Which Unity version do you use? Are there errors in the logs, aside from this?

Answers

  • PUN2 v2.40(Latest)

    2.41 is the latest. Even if that's not the solution, please update.

    It is very likely there is some antivirus tool installed, that provides internet security and blocks the connection in browser.

    I replied to reports like this several times today. If you crossposted this a lot: Please don't do that. It takes extra time on our side and support will suffer. Be patient. Debug the situation as good as you can.

  • gaurav_sud
    edited October 2022

    I got pun2 updated to v2.41 still having the same issue.

    I just want to know is there any changes in PhotonServerSettings or any other that needs to be made.

    If not then I will try to Debug on my own.


    Can this be a problem?

    how can I access Https?

    The webpage at wss://ns.photonengine.io:19093/ might be temporarily down or it may have moved permanently to a new web address.

    (I don't have much Idea about wss).

  • Tobias
    Tobias admin
    Answer ✓

    If you use PUN 2, you only have to enter your AppId in the PhotonServerSettings, switch the build target to WebGL and build. Nothing else needs to change. A WebGL build will automatically use the right connection type.

    I would test this: Create a new, empty project, import PUN 2 and check the version number shown in the PhotonServerSettings inspector. Insert the AppId and build one of our demos for WebGL (no changes by you).

    If this doesn't work on your machine via build and run, try another machine and or another network (the problem is not on the server side or such).

    Which Unity version do you use? Are there errors in the logs, aside from this?

  • Thanks for suggesting to try on another machine that solved my issue but I am still confused why it is not working on my own system.

  • It might be some network security setting / tool, the router or .. a lot of other causes. It may be quite tricky to find out, if it's not just your machine (which you could test by using some other laptop in the same network)...