Android not respecting Server IP address and tries to connect to 127.0.0.1

Pun 2.19.3
Photon lib 4.1.4.4


I have tried both
PhotonNetwork.ConnectToMaster("3.X.x.x.x", 5055, "XXXX");
and
PhotonNetwork.PhotonServerSettings.AppSettings.Server = "3.X.X.X";
PhotonNetwork.PhotonServerSettings.AppSettings.Port = 5055;
PhotonNetwork.PhotonServerSettings.AppSettings.UseNameServer = false;
PhotonNetwork.PhotonServerSettings.AppSettings.FixedRegion = null;
PhotonNetwork.ConnectUsingSettings();

all while having the settings stored in the PhotonServerSettings file.


On my PC build - I can connect and it seems fine, but when I make a Android build, mind you no other changes to the code... it does this:


I do not have anything associated with 127.0.0.1 - I don't know why its trying to connect locally, as that will NOT work. its a phone and its not the correct IP.


2021-04-28 18:28:59.639 27270-8588/com.E E/Unity: Receive issue. State: Connected. Server: '127.0.0.1' ErrorCode: 10061 SocketErrorCode: ConnectionRefused Message: Connection refused System.Net.Sockets.SocketException (0x80004005): Connection refused
at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00000] in <00000000000000000000000000000000>:0
at System.Net.Sockets.Socket.Receive (System.Byte[] buffer) [0x00000] in <00000000000000000000000000000000>:0
at ExitGames.Client.Photon.SocketUdp.ReceiveLoop () [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
at System.Threading.Execut
2021-04-28 18:28:59.643 27270-8588/com.E E/Unity: PHOTON_PUNOnDisconnected cause=Exception
UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
UnityEngine.Logger:LogFormat(LogType, String, Object[])
UnityEngine.Debug:LogErrorFormat(String, Object[])
PhotonConnect:OnDisconnected(DisconnectCause)
Photon.Realtime.ConnectionCallbacksContainer:OnDisconnected(DisconnectCause)
Photon.Realtime.LoadBalancingClient:OnStatusChanged(StatusCode)
ExitGames.Client.Photon.<>c__DisplayClass110_0:<EnqueueStatusCallback>b__0()
ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
Photon.Pun.PhotonHandler:Dispatch()
Photon.Pun.PhotonHandler:FixedUpdate()

Comments

  • There should be no Android specific code in PUN 2 that could affect this.
    Before we chase a bug that may be fixed since, you should update to v2.30, check again.
    Important: We recently removed the setting for the protocol 1.6 when using your own server (we also released a v5 Server SDK beta, which should be used for any current development).
    Set the serialization protocol, as described in the changelog.

    Debug.Log where you set the server's IP and check the runtime logs that this code is running.
  • I would prefer not to be using BETA software for this... Its also not available on the website? Unless I am missing it somewhere?
    I will try updating PUN today... Didn't see it listed in the change logs
  • After upgrading PUN - now I can't connect to my server at all...
    https://imgur.com/a/irvxpYw
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @gfalk,

    Set PhotonNetwork.NetworkingClient.SerializationProtocol = SerializationProtocol.GpBinaryV16 before connecting.
    This was changed in PUN 2.29.
    Sorry for the inconvenience.

    Photon Server v5 beta SDK & documentation were taken down from our websites.
    Photon Server v5 RC will be released soon in May.
  • same error....

    Pun 2.3.0
    photon lib 4.1.5.2


    PhotonNetwork.PhotonServerSettings.AppSettings.Server = "3.XXX";
    PhotonNetwork.PhotonServerSettings.AppSettings.Port = 5055;
    PhotonNetwork.PhotonServerSettings.AppSettings.UseNameServer = false;
    PhotonNetwork.PhotonServerSettings.AppSettings.FixedRegion = null;


    PhotonNetwork.NetworkingClient.SerializationProtocol = SerializationProtocol.GpBinaryV16;

    PhotonNetwork.ConnectToMaster("3.XXX", 5055, "19be2XXX");



    2021-05-03 10:50:04.056 18889-8120/com.E E/Unity: Receive issue. State: Connected. Server: '127.0.0.1' ErrorCode: 10061 SocketErrorCode: ConnectionRefused Message: Connection refused System.Net.Sockets.SocketException (0x80004005): Connection refused
    at System.Net.Sockets.Socket.Receive (System.Byte[] buffer, System.Int32 offset, System.Int32 size, System.Net.Sockets.SocketFlags socketFlags) [0x00000] in <00000000000000000000000000000000>:0
    at System.Net.Sockets.Socket.Receive (System.Byte[] buffer) [0x00000] in <00000000000000000000000000000000>:0
    at ExitGames.Client.Photon.SocketUdp.ReceiveLoop () [0x00000] in <00000000000000000000000000000000>:0
    at System.Threading.ThreadHelper.ThreadStart_Context (System.Object state) [0x00000] in <00000000000000000000000000000000>:0
    at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, System.Object state, System.Boolean preserveSyncCtx) [0x00000] in <00000000000000000000000000000000>:0
    at System.Threading.Execut
    2021-05-03 10:50:04.058 18889-8120/com.E E/Unity: PHOTON_PUNOnDisconnected cause=Exception
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:LogFormat(LogType, String, Object[])
    UnityEngine.Debug:LogErrorFormat(String, Object[])
    PhotonConnect:OnDisconnected(DisconnectCause)
    Photon.Realtime.ConnectionCallbacksContainer:OnDisconnected(DisconnectCause)
    Photon.Realtime.LoadBalancingClient:OnStatusChanged(StatusCode)
    ExitGames.Client.Photon.<>c__DisplayClass111_0:<EnqueueStatusCallback>b__0()
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    Photon.Pun.PhotonHandler:Dispatch()
    Photon.Pun.PhotonHandler:FixedUpdate()




    2021-05-03 10:53:28.116 18131-10281/com.E W/Unity: [0.0] SupportLogger Info: AppID: "" AppVersion: "" Client: v4.1.5.2 (NetStandard20) Build: 2020.2.5f1, Android, ENABLE_IL2CPP, DEBUG, NET_STANDARD_2_0 UserId: "" AuthType: N/A AuthMode: Auth PayloadEncryption State: PeerCreated PeerID: 65535 NameServer: ns.exitgames.com Current Server: IP: Region:
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:LogWarning(Object)
    Photon.Realtime.SupportLogger:LogBasics()
    Photon.Realtime.SupportLogger:Start()
    2021-05-03 10:53:38.054 18131-10281/com.E I/Unity: [9.937] SupportLogger OnConnected().
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:Log(Object)
    Photon.Realtime.SupportLogger:OnConnected()
    Photon.Realtime.ConnectionCallbacksContainer:OnConnected()
    Photon.Realtime.LoadBalancingClient:OnStatusChanged(StatusCode)
    ExitGames.Client.Photon.PeerBase:InitCallback()
    ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer)
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    Photon.Pun.PhotonHandler:Dispatch()
    Photon.Pun.PhotonHandler:FixedUpdate()
    2021-05-03 10:53:38.056 18131-10281/com.E W/Unity: [9.939] SupportLogger Info: AppID: "19be2ec7***" AppVersion: "" Client: v4.1.5.2 (NetStandard20) Build: 2020.2.5f1, Android, ENABLE_IL2CPP, DEBUG, NET_STANDARD_2_0 Socket: SocketUdp UserId: "" AuthType: N/A AuthMode: Auth PayloadEncryption State: ConnectingToMasterServer PeerID: 252 NameServer: ns.exitgames.com Current Server: 3.81.131.1:5055 IP: 3.81.131.1:5055 Region:
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:LogWarning(Object)
    Photon.Realtime.SupportLogger:LogBasics()
    Photon.Realtime.SupportLogger:OnConnected()
    Photon.Realtime.ConnectionCallbacksContainer:OnConnected()
    Photon.Realtime.LoadBalancingClient:OnStatusChanged(StatusCode)
    ExitGames.Client.Photon.PeerBase:InitCallback()
    ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer)
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    Photon.Pun.PhotonHandler:Dispatch()
    Photon
    2021-05-03 10:53:38.250 18131-10281/com.EI/Unity: [10.133] SupportLogger OnConnectedToMaster().
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:Log(Object)
    Photon.Realtime.SupportLogger:OnConnectedToMaster()
    Photon.Realtime.ConnectionCallbacksContainer:OnConnectedToMaster()
    Photon.Realtime.LoadBalancingClient:OnOperationResponse(OperationResponse)
    ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer)
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    Photon.Pun.PhotonHandler:Dispatch()
    Photon.Pun.PhotonHandler:FixedUpdate()
    2021-05-03 10:53:42.104 18131-10281/com.E I/Unity: [13.988] SupportLogger OnDisconnected(Exception).
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:Log(Object)
    Photon.Realtime.SupportLogger:OnDisconnected(DisconnectCause)
    Photon.Realtime.ConnectionCallbacksContainer:OnDisconnected(DisconnectCause)
    Photon.Realtime.LoadBalancingClient:OnStatusChanged(StatusCode)
    ExitGames.Client.Photon.<>c__DisplayClass111_0:<EnqueueStatusCallback>b__0()
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    Photon.Pun.PhotonHandler:Dispatch()
    Photon.Pun.PhotonHandler:FixedUpdate()
    2021-05-03 10:53:42.104 18131-10281/com.E W/Unity: [13.988] SupportLogger Info: AppID: "19be2ec7***" AppVersion: "" Client: v4.1.5.2 (NetStandard20) Build: 2020.2.5f1, Android, ENABLE_IL2CPP, DEBUG, NET_STANDARD_2_0 Socket: SocketUdp UserId: "" AuthType: N/A AuthMode: Auth PayloadEncryption State: Disconnected PeerID: 65535 NameServer: ns.exitgames.com Current Server: 127.0.0.1:5056 IP: 127.0.0.1:5056 Region:
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:LogWarning(Object)
    Photon.Realtime.SupportLogger:LogBasics()
    Photon.Realtime.SupportLogger:OnDisconnected(DisconnectCause)
    Photon.Realtime.ConnectionCallbacksContainer:OnDisconnected(DisconnectCause)
    Photon.Realtime.LoadBalancingClient:OnStatusChanged(StatusCode)
    ExitGames.Client.Photon.<>c__DisplayClass111_0:<EnqueueStatusCallback>b__0()
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    Photon.Pun.PhotonHandler:Dispatch()
    Photon.Pun.PhotonHandler:Fixe
    2021-05-03 10:53:42.104 18131-10281/com.E I/Unity: [13.989] SupportLogger Rtt(variance): 200(5). Since receive: 80ms. Longest send: 1ms. Stats elapsed: 0sec.
    Longest delta between Send: 0ms Dispatch: 29ms. Longest callback OnEv: 0=0ms OnResp: 0=0ms. Calls of Send: 1 Dispatch: 3. Ping min/max: 58/200
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:Log(Object)
    Photon.Realtime.SupportLogger:LogStats()
    Photon.Realtime.SupportLogger:OnDisconnected(DisconnectCause)
    Photon.Realtime.ConnectionCallbacksContainer:OnDisconnected(DisconnectCause)
    Photon.Realtime.LoadBalancingClient:OnStatusChanged(StatusCode)
    ExitGames.Client.Photon.<>c__DisplayClass111_0:<EnqueueStatusCallback>b__0()
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    Photon.Pun.PhotonHandler:Dispatch()
    Photon.Pun.PhotonHandler:FixedUpdate()
    2021-05-03 10:53:47.347 18131-10281/com.E.EI/Unity: [19.230] SupportLogger OnConnected().
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:Log(Object)
    Photon.Realtime.SupportLogger:OnConnected()
    Photon.Realtime.ConnectionCallbacksContainer:OnConnected()
    Photon.Realtime.LoadBalancingClient:OnStatusChanged(StatusCode)
    ExitGames.Client.Photon.PeerBase:InitCallback()
    ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer)
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    Photon.Pun.PhotonHandler:Dispatch()
    Photon.Pun.PhotonHandler:FixedUpdate()
    2021-05-03 10:53:47.347 18131-10281/com.E.E W/Unity: [19.231] SupportLogger Info: AppID: "19be2ec7***" AppVersion: "" Client: v4.1.5.2 (NetStandard20) Build: 2020.2.5f1, Android, ENABLE_IL2CPP, DEBUG, NET_STANDARD_2_0 Socket: SocketUdp UserId: "" AuthType: N/A AuthMode: Auth PayloadEncryption State: ConnectingToMasterServer PeerID: 253 NameServer: ns.exitgames.com Current Server: 3.81.131.1:5055 IP: 3.81.131.1:5055 Region:
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:LogWarning(Object)
    Photon.Realtime.SupportLogger:LogBasics()
    Photon.Realtime.SupportLogger:OnConnected()
    Photon.Realtime.ConnectionCallbacksContainer:OnConnected()
    Photon.Realtime.LoadBalancingClient:OnStatusChanged(StatusCode)
    ExitGames.Client.Photon.PeerBase:InitCallback()
    ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer)
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    Photon.Pun.PhotonHandler:Dispatch()
    Photo
    2021-05-03 10:53:47.644 18131-10281/com.E.EI/Unity: [19.528] SupportLogger OnConnectedToMaster().
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:Log(Object)
    Photon.Realtime.SupportLogger:OnConnectedToMaster()
    Photon.Realtime.ConnectionCallbacksContainer:OnConnectedToMaster()
    Photon.Realtime.LoadBalancingClient:OnOperationResponse(OperationResponse)
    ExitGames.Client.Photon.PeerBase:DeserializeMessageAndCallback(StreamBuffer)
    ExitGames.Client.Photon.EnetPeer:DispatchIncomingCommands()
    ExitGames.Client.Photon.PhotonPeer:DispatchIncomingCommands()
    Photon.Pun.PhotonHandler:Dispatch()
    Photon.Pun.PhotonHandler:FixedUpdate()
    2021-05-03 10:53:57.376 18131-10281/com.E.E I/Unity: [29.259] SupportLogger Rtt(variance): 79(11). Since receive: 891ms. Longest send: 1ms. Stats elapsed: 10sec.
    Longest delta between Send: 127ms Dispatch: 127ms. Longest callback OnEv: 0=0ms OnResp: 0=2ms. Calls of Send: 191 Dispatch: 518. Ping min/max: 72/79
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:Log(Object)
    Photon.Realtime.SupportLogger:LogStats()
    2021-05-03 10:54:07.374 18131-10281/com.E.EI/Unity: [39.258] SupportLogger Rtt(variance): 77(6). Since receive: 787ms. Longest send: 1ms. Stats elapsed: 20sec.
    Longest delta between Send: 127ms Dispatch: 127ms. Longest callback OnEv: 0=0ms OnResp: 0=2ms. Calls of Send: 362 Dispatch: 1019. Ping min/max: 72/79
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:Log(Object)
    Photon.Realtime.SupportLogger:LogStats()
    2021-05-03 10:54:17.358 18131-10281/com.E.EI/Unity: [49.242] SupportLogger Rtt(variance): 74(5). Since receive: 805ms. Longest send: 1ms. Stats elapsed: 30sec.
    Longest delta between Send: 127ms Dispatch: 127ms. Longest callback OnEv: 0=0ms OnResp: 0=2ms. Calls of Send: 547 Dispatch: 1519. Ping min/max: 72/79
    UnityEngine.DebugLogHandler:LogFormat(LogType, Object, String, Object[])
    UnityEngine.Logger:Log(LogType, Object)
    UnityEngine.Debug:Log(Object)
    Photon.Realtime.SupportLogger:LogStats()
  • ???
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @gfalk,

    it looks like you manage to connect to Master since the SupportLogger.OnConnectedToMaster logs.
    and the error/exception happens before that.

    also the server is '127.0.0.1' which is different from "3.XXX" what you pass to PhotonNetwork.ConnectToMaster.
    so either there is another connect call before that or you fail connecting to GameServer which is configured to use 127.0.0.1?

    It's most likely that you have two Connect calls.

    Side note:
    We recommend that you set AppSettings via PhotonServerSettings ScriptableObject inspector from Unity Editor and simply call PhotonNetwork.ConnectUsingSettings.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @gfalk,

    In case you missed it Photon Server v5 RC1 is out.