Fail to connect on local Photon Server with WebSocket

Options
Hi,
I have a simple setup:

- I have downloaded the server sdk v5 and it is running I have not modified the settings except for the NameServer.json where I changed the ipAdress to 127.0.0.1 and the server is now running on my computer


- On the same computer I have a Unity project with a simple scene that tries to connect to the server using "PhotonNetzork.ConnectUsingSettings()" with the following params:

Use Name Server: false
Fixed region: EU
Server: ws://127.0.0.1
Port: 9090
Protocol: WebSocket


When I start the game inside the editor I get immediatly this error:
"ClientWebSocket IsFaulted: System.AggregateException: One or more errors occurred. ---> System.Net.WebSockets.WebSocketException: Unable to connect to the remote server
at System.Net.WebSockets.WebSocketHandle+<ParseAndValidateConnectResponseAsync>d__28.MoveNext () [0x00107] in <aa976c2104104b7ca9e1785715722c9d>:0 (...)"

And everything work properly when I change the params to:

Use Name Server: false
Fixed region: EU
Server: 127.0.0.1
Port: 5055
Protocol: UDP

Am I doing something wrong or did I forget a step in order to make web socket work?
Any help would be much appreciated because I have been stuck with the server setup for a long time :(

Thanks in advance

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @ClownCitron,

    Thank you for choosing Photon!

    Did you see this?
  • ClownCitron
    Options
    Okay thanks a lot that's what I needed :)

    But, now that I have been able to make the websocket connexion work on my local computer I have to make it work by SecureWebSocket to a remote server but I struggling a lot... I might be missing a step or something.

    I have my Photon server runnning on a VPS which is linked with a domain name xxx.fr and I have followed the 5 steps from the doc: https://doc.photonengine.com/zh-CN/server/current/operations/certificate-setup

    I generated a certificate by Let's Encrypt with certbot and combined the key and the certificate into 'server.pem'.

    In the PhotonServer.config I uncommented the following lines:

    "
    <HTTPListener Name="*:[PORT]::Master" IPAddress="0.0.0.0" Port="19090" DisableNagle="true"
    InactivityTimeout="10000" Secure="true" StoreName="Personal" CertificateNAme="escapegamelinky.fr"
    UseMachineStore="true">
    <Routing>
    <Route Url="/+" OverrideApplication="Master" PeerType="WebSocket" Counters="false" />
    </Routing>
    </HTTPListener>

    <HTTPListener Name="*:[PORT]::Game" IPAddress="0.0.0.0" Port="19091" DisableNagle="true" InactivityTimeout="10000"
    AppDataInactivityTimeout="15000" Secure="true" StoreName="Personal" CertificateNAme="escapegamelinky.fr"
    UseMachineStore="true">
    <Routing>
    <Route Url="/+" OverrideApplication="Game" PingEvery="2000" PeerType="WebSocket" Counters="false" />
    </Routing>
    </HTTPListener>

    <HTTPListener Name="*:[PORT]::NameServer" IPAddress="0.0.0.0" Port="19093" DisableNagle="true"
    InactivityTimeout="10000" AppDataInactivityTimeout="15000" Secure="true" StoreName="Personal"
    CertificateNAme="escapegamelinky.fr" UseMachineStore="true">
    <Routing>
    <Route Url="/+" OverrideApplication="NameServer" PeerType="WebSocket" Counters="false" />
    </Routing>
    </HTTPListener>
    "


    And now when I try to connect with my client (in the Unity Editor) with the following params I get an error:

    Params:
    Use Name Server: false
    Server: wss://xxx.fr
    Port: 19090
    Protocol: WebSocketSecure

    Error:
    "
    ClientWebSocket IsFaulted: System.AggregateException: One or more errors occurred. ---> System.Net.WebSockets.WebSocketException: Unable to connect to the remote server ---> System.OperationCanceledException: The operation was canceled. ---> System.ObjectDisposedException: Cannot access a disposed object.
    Object name: 'System.Net.Sockets.Socket'.
    at System.Net.Sockets.Socket.BeginConnect (System.Net.IPAddress address, System.Int32 port, System.AsyncCallback requestCallback, System.Object state) [0x0001b] in <aa976c2104104b7ca9e1785715722c9d>:0
    at System.Net.Sockets.SocketTaskExtensions+<>c.<ConnectAsync>b__3_0 (System.Net.IPAddress targetAddress, System.Int32 targetPort, System.AsyncCallback callback, System.Object state) [0x00000] in <aa976c2104104b7ca9e1785715722c9d>:0
    at System.Threading.Tasks.TaskFactory`1[TResult].FromAsyncImpl[TArg1,TArg2] (System.Func`5[T1,T2,T3,T4,TResult] beginMethod, System.Func`2[T,TResult] endFunction, System.Action`1[T] endAction, TArg1 arg1, TArg2 arg2, System.Object state, System.Threading.Tasks.TaskCreationOptions creationOptions) [0x00170] in <695d1cc93cca45069c528c15c9fdd749>:0
    ...
    "

    And I openned the following ports on Windows firewall: 19090,19091,19093.
    Do I need to open other ports?

    Any Idea of what step I might have forgotten or done wrong?

    Thanks
  • ClownCitron
    Options
    And sorry I don't really understand..
    Do I have to change something in the NameServer.json file?