PUN to PASK connection on Azure emulator

Hello,

I read the PASK guide and was able to connect PUN to cloud worker on Azure, but having an issue doing so locally. As far as I understand, PASK in local environment doesn’t support UDP, so I have to connect through TCP ports and specifically the 4530 one? So I start LoadBalancing project debugging in VS (compute and storage emulators startup normally as well), setup PUN in self hosted mode and set IP 127.0.0.1 and port 4530, but on connection I have a fail and this 3 guys saying:
Error trying to receive. Exception: System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host.
Exception while connecting to: 127.0.0.1:4530. Check if the server is available.
The server address is 127.0.0.1 (localhost): Make sure the server is running on this machine. Android and iOS emulators have their own localhost.

I tried telnet 127.0.0.1 4530 and it seems to be working just like it was with cloud worker, so I just have no idea, why Unity can’t see it… I also tried using different ports, but it was all the same.

Comments

  • Elringus wrote:
    ... As far as I understand, PASK in local environment doesn’t support UDP, so I have to connect through TCP ports and specifically the 4530 one?

    I guess the documentation needs a bit of clarification in that point ...

    In the emulator the instances ramped up get the IPs 127.255.0.{instanceindex} meaning that if you start 3 nodes they will have the ip's
    127.255.0.0
    127.255.0.1
    127.255.0.2
    where the master will be always the first 127.255.0.0.

    So you should be able to connect to the well known ports Udp=5055, Tcp=4530 on 127.255.0.0.

    You can check the logs in C:\photon-logs\instance_0\Photon\Photon-Default0-XXXXXX.log to see what photon is being setup with, you should see something like:

    69340: 16:07:11.602 - Forcing all applications ids to: "Master"
    69340: 16:07:11.602 - Routing policy file requests to: "Policy"
    69340: 16:07:11.602 - Adding TCP listener on :127.255.0.0: 10300 with a listen backlog of: 150
  • Thanks for the explanation. I managed connecting to 127.255.0.0:5055, but now I’m having a strange issue on creating room. When executing PhotonNetwork.CreateRoom("test") following error appears in Unity console:
    Error trying to receive. Exception: System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host.
    at System.Net.Sockets.Socket.Receive (System.Byte[] buffer) [0x00000] in <filename unknown>:0
    at ExitGames.Client.Photon.NConnect.Run () [0x00000] in <filename unknown>:0

    And here is what I get in MSMaster.log at the same time:

    [code2=plain]2013-02-14 15:36:24,318 [14] DEBUG Photon.LoadBalancing.MasterServer.MasterApplication [(null)] - Received init request from game client on leader node
    2013-02-14 15:36:24,375 [13] DEBUG Photon.LoadBalancing.MasterServer.MasterClientPeer [(null)] - OnOperationRequest: pid=1, op=252
    2013-02-14 15:36:24,432 [10] DEBUG Photon.LoadBalancing.MasterServer.MasterClientPeer [(null)] - OnOperationRequest: pid=1, op=230
    2013-02-14 15:36:24,483 [12] DEBUG Photon.LoadBalancing.MasterServer.MasterClientPeer [(null)] - OnOperationRequest: pid=1, op=229
    2013-02-14 15:36:25,797 [13] DEBUG Photon.LoadBalancing.MasterServer.MasterClientPeer [(null)] - OnOperationRequest: pid=1, op=252
    2013-02-14 15:36:25,797 [13] DEBUG Photon.LoadBalancing.MasterServer.MasterClientPeer [(null)] - OnOperationRequest: pid=1, op=227
    2013-02-14 15:36:25,798 [13] DEBUG Photon.LoadBalancing.MasterServer.Lobby.GameState [(null)] - Added peer: gameId=test, userId=, joiningPeers=1
    2013-02-14 15:36:25,816 [13] DEBUG Photon.LoadBalancing.MasterServer.MasterClientPeer [(null)] - Disconnect: pid=1: reason=ClientDisconnect, detail=[/code2]
    I looked through other logs, but was unable to find anything, that could explain the cause of the problem.
    Again, it’s working perfectly on the cloud, but fails for Azure emulator.
  • I also checked PhotonNetwork.connectionStateDetailed data while creating room, if this could help:
    First it's "JoinedLobby" while I'm in lobby after successful connection, then, after executing PhotonNetwork.CreateRoom() it’s changing to “DisconnectingFromMasterserver”, then “ConnectingToGameserver”, then “System.Net.Sockets.SocketException” rises and after all it stays as “PeerCreated”.
  • I just checked and can confirm your issue - sorry about that.

    Its a miss confuguration in the Photon.Azure.Loadbalancing.dll.config the ports have to be configured like this:

    [code2=xml]<Photon.LoadBalancing.GameServer.GameServerSettings>
    ...
    <setting name="GamingTcpPort" serializeAs="String">
    <value>10300</value>
    </setting>
    <setting name="GamingUdpPort" serializeAs="String">
    <value>10400</value>
    </setting>
    <setting name="GamingWebSocketPort" serializeAs="String">
    <value>10500</value>
    </setting>[/code2]

    To FIX the issue: make the change to the file, rebuild and upload AzureLoadbalancing to the local storage!

    After the change you should see something like this in the the Master.log:

    [code2=plain]2013-02-19 12:16:59,822 [13] DEBUG Photon.LoadBalancing.MasterServer.GameServer.IncomingGameServerPeer [(null)] - Received register request: Address=127.255.0.1, UdpPort=10400, TcpPort=10300, WebSocketPort=10500, State=Normal[/code2]

    Notice the ports being reported (10300-10500) are also beeing reported in the Photon-Default0-XXXX.log - as endpoints photon is listening on:

    [code2=plain]76 11040: 12:16:58.322 - Adding TCP listener on :127.255.0.0: 4530 with a listen backlog of: 150
    83 11040: 12:16:58.322 - Adding TCP listener on :127.255.0.0: 10300 with a listen backlog of: 150
    90 11040: 12:16:58.322 - Adding TCP listener on :127.255.0.0: 4520 with a listen backlog of: 150
    98 11040: 12:16:58.322 - Adding UDP listener on :127.255.0.0: 5055 with a listen backlog of: 500
    102 11040: 12:16:58.322 - Adding UDP listener on :127.255.0.0: 10400 with a listen backlog of: 500
    103 11040: 12:16:58.322 - Adding TCP Policy listener on :127.255.0.0: 843 with a listen backlog of: 150 and routing to application: "Policy"
    105 11040: 12:16:58.322 - Adding TCP Policy listener on :127.255.0.0: 943 with a listen backlog of: 150 and routing to application: "Policy"
    107 11040: 12:16:58.323 - Adding TCP "Chunk" listener on :127.255.0.0: 666 with a listen backlog of: 150 and routing to application: "Master"
    111 11040: 12:16:58.323 - Adding WebSocket TCP listener on :127.255.0.0: 9090 with a listen backlog of: 150
    119 11040: 12:16:58.323 - Adding WebSocket TCP listener on :127.255.0.0: 10500 with a listen backlog of: 150[/code2]

    To see that its working it might be easier to test with {sdk}\src-server\LoadBalancing\TestClient.
    Change the app.config to

    [code2=xml]<appSettings>
    <add key="ServerAddress" value="127.255.0.0" />
    <!-- game settings -->
    <add key="NumClientsPerGame" value="2" />
    <add key="NumGames" value="1" />
    <add key="ClientSettingsProvider.ServiceUri" value="" />
    </appSettings>[/code2]

    before the change you see the client trying to connect to a port Photon isn't listening on:
    [code2=plain]2013-02-19 11:58:34,584 [3] DEBUG Photon.LoadBalancing.TestClient.ConnectionStates.GameServer - GAME: Connecting to game server at 127.255.0.0:4531
    2013-02-19 11:58:34,581 [3] DEBUG Photon.LoadBalancing.TestClient.ConnectionStates.Master - MASTER: Create game response: address=127.255.0.0:4531, gameId=MYPC(10556)1[/code2]

    after the change you should see the correct port beeing used:
    [code2=plain]2013-02-19 12:17:58,823 [7] DEBUG Photon.LoadBalancing.TestClient.ConnectionStates.Master - MASTER: Create game response: address=127.255.0.1:10300, gameId=MYPC(10164)1
    2013-02-19 12:17:58,826 [7] DEBUG Photon.LoadBalancing.TestClient.ConnectionStates.GameServer - GAME: Connecting to game server at 127.255.0.1:10300[/code2]
  • Note: that to develop and test your custom code in the Master or the Gameserver apps you don't need to start them using the azure emulator - its easier just starting your apps in one photon instance as we do when you "just" start loadbalancing in the photon control.
Sign In or Register to comment.