Can't to connect to photon server in WebGL websocket and websocketsecure

ntquang1999
edited March 2022 in Photon Server

Hi,

I'm pretty new to networking. Right now I'm using latest PUN 2 package, using the Asteroid Demo to connect to a server I hosted on same machine, my personal computer. I use both v4 and v5, leave default config and get the Demo run on UDP normally.

But when I change to WebGL and change connect protocol to Websocket or WSS, the client can't connect. It still can connect to Photon Cloud via AppID normally.

The error is: Exiting receive thread. Server: ws://127.0.0.1:9093:0 Error: Abnormal disconnection.

Edit: I notice the weird ":0" in the URL, then I log out the real url that connect:

WebSocket connection to 'ws://127.0.0.1:9093/?libversion=4.1.6.11&sid=30&app=NameServer' failed:

My client photon settings are bellow

Are there any other thing I need to config so it can run?


Answers

  • @ntquang1999 do you see that port is set to 0 although it should be 9090 for WS and 19090 for WSS. Please note that for WSS you have to provide certificate

    best,

    ilya

  • JohnTube
    JohnTube ✭✭✭✭✭

    Hi @ntquang1999,

    Thank you for choosing Photon!

    I wanted to clarify that in PUN's PhotonServerSettings if you keep port 0, the default NameServer port per protocol will be used. In this case (WebSockets), it will be 9093.

    Please test using UDP or TCP first then switch to WebSockets (not WebSocketsSecure).

    Not sure what is the exact failure reason. Could you paste full error message you get on the client? Also, did you check server logs?

  • I set 9090 and still doesn't work. Then I try to remove the * on the url = "/*" of the NameServer config, then I can connect on local. I thought problem solve but when I switch to using LAN, change IP to 192.168.1.155, the others machine run on LAN can connect to Nameserver but not Masterserver


  • JohnTube
    JohnTube ✭✭✭✭✭

    Hi @ntquang1999,

    Please replace "/*" with "/+".

  • JohnTube
    JohnTube ✭✭✭✭✭
    • "/*" is not supported (at least not in v5 RC1).
    • + or * are probably RegEx thing: *: any zero or more chars, +: any one or more chars? I'm not sure, though, @chvetsov may confirm.
    • "/" is simply no relative path, just root endpoint.
  • hi, @ntquang1999

    /+ it is not regexp. it is just our way to do it.

    best,

    ilya