How to connect to self-hosted server in webgl case?

Options
epishinvit
edited March 2022 in Photon Server

Dear,

Unfortunately, we have faced an issue with the Photon server while porting our game to the WebGL Platform.

We are using the WSS connection protocol, and everything works well in the Editor, but the WebGL build doesn't connect our backend and gives no errors.

After research, we have found that the WSS protocol uses ClientWebSocket to perform the connection process. That looks like the ClientWebSocket shouldn't work on the WebGL platform.

Could you please provide some additional info on how we could solve this issue?

Best Answer

  • Tobias
    Tobias admin
    Answer ✓
    Options

    In WebGL, you need the PhotonLibs\WebSocket folder in your project. It should automatically compile and then use the SocketWebTcp / WebSocket classes, which wrap the js lib in the browser but the WebSocket-sharp in Editor (so both can use WSS).

    Make sure you don't set the PhotonClientWebSocket anywhere as websocket implementation.

Answers

  • Tobias
    Tobias admin
    Answer ✓
    Options

    In WebGL, you need the PhotonLibs\WebSocket folder in your project. It should automatically compile and then use the SocketWebTcp / WebSocket classes, which wrap the js lib in the browser but the WebSocket-sharp in Editor (so both can use WSS).

    Make sure you don't set the PhotonClientWebSocket anywhere as websocket implementation.

  • epishinvit
    edited March 2022
    Options

    We have that folder and implementation. But PhotonPeer class (we uses it for connection) implement PhotonClientWebSocket in WSS case. I tryed set SocketWebTcp implementation manualy after construct PhotonPeer object and it's work fine. Should we do it by this way or we can use some settings or correct version of PhotonPeer?