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

The whole answer can be found below.

Please note: The Photon forum is closed permanently. After many dedicated years of service we have made the decision to retire our forum and switch to read-only: we've saved the best to last! And we offer you support through these channels:

Try Our
Documentation

Please check if you can find an answer in our extensive documentation on Photon Server.

Join Us
on Discord

Meet and talk to our staff and the entire Photon-Community via Discord.

Read More on
Stack Overflow

Find more information on Stack Overflow (for Circle members only).

Write Us
an E-Mail

Feel free to send your question directly to our developers.

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

ntquang1999
2022-03-23 07:02:43

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?

Comments

chvetsov
2022-03-23 08:03:41

@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
2022-03-23 10:46:23

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?

ntquang1999
2022-03-23 20:33:29

chvetsov 2022-03-23T08:03:41+00:00

@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

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
2022-03-23 20:34:30

Hi @ntquang1999,

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

ntquang1999
2022-03-24 04:31:56

What are the differences between "/*" , "/+" and "/"

JohnTube 2022-03-23T20:34:30+00:00

Hi @ntquang1999,

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

JohnTube
2022-03-24 11:17:07

  • "/*" 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.

chvetsov
2022-03-24 16:35:03

hi, @ntquang1999

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

best,

ilya

Back to top