Why can't I connect to my server anymore?

Options
I can connect from the host machine for obvious reasons (as seen from this error message below) but only the host machine.. I am hosting over tcp and the connection is NOT set to 127.0.0.1 in the photon settings in unity, it's set to the ip address that it should be, I'm not sure why it is trying to connect to 127.0.0.1... where do I need to change the ip it's connecting to?

Connect() to '127.0.0.1' failed: System.Net.Sockets.SocketException (0x80004005): No connection could be made because the target machine actively refused it. at System.Net.Sockets.Socket.Connect (System.Net.EndPoint remoteEP) [0x000b6] in <93cc5a601cf645d2a15a96c4600351ac>:0 at System.Net.Sockets.Socket.Connect (System.Net.IPAddress address, System.Int32 port) [0x00008] in <93cc5a601cf645d2a15a96c4600351ac>:0 at ExitGames.Client.Photon.SocketTcp.DnsAndConnect () [0x00088] in <5bac2b0d73684de1adac4ad02bdde90d>:0 UnityEngine.Debug:LogError(Object) NetworkingPeer:DebugReturn(DebugLevel, String) (at Assets/Extensions/Networking/Photon Unity Networking/Plugins/PhotonNetwork/NetworkingPeer.cs:1574) ExitGames.Client.Photon.SocketTcp:DnsAndConnect() System.Threading.ThreadHelper:ThreadStart()

Answers

  • Bump.
    I'm just trying to see if there is another place I need to change the ip in the configuration files or something.
  • So far from debugging I've found on line 1913 of NetworkingPeer.cs
    this.GameServerAddress = (string)operationResponse[ParameterCode.Address];
    Sets the GameServerAddress to 127.0.0.1
    But I can't seem to get past here...

    I'm not sure where and how the value of operationResponse is set.
  • I'm self-hosting on TCP. I configured the photon server settings to match.
  • Hi @DDeathlonger,

    Have you already checked, if you set the IP somewhere in code?

    Do you use PhotonNetwork.ConnectUsingSettings or PhotonNetwork.ConnectToMaster in order to connect to the server. If you use the first one, please make sure, that the correct IP and Port is set in the PhotonServerSettings. I think you can also uncheck the 'Use Name Server' option. If you use the second one, please make sure, that you use the correct IP address and port as function parameters.
  • Thank you @Christian_Simon for the response, as I previous stated, I have set them correctly in the PhotonServerSettings
    I configured the photon server settings to match.

    Thereby I also use PhotonNetwork.ConnectUsingSettings()

    Have you already checked, if you set the IP somewhere in code?

    that's what I meant, I know I haven't within my personal code... but I do set the authTokens in a separate script... does that reset the connection or anything? Otherwise I'm not sure where I could have even changed the IP which is stored.
  • Have you already tried without AuthValues and AuthTokens? Is there any difference?

    If there isn't any difference, can you please explain the setup you have again? Is the server running on the same machine as the client? I'm not sure if I understood this correctly. In my tests, I have the server running on the same machine as the client and don't have any problems with it. If you have server and client separated on different machines, are those machines in the same network?
  • DDeathlonger
    edited October 2018
    Options
    Ignore, can't delete, posted this before the page refreshed showing the response from Christian

    Anyone know any alternative locations for where the IP might be set, so that I can verify that it is what it needs to be?
  • @Christian_Simon Thank you for the response, I'll check my whole order of setup especially around the authvalues/tokens,

    If i am not mistaken, AuthValues contains a set of AuthTokens. so they are separate but related in this manner.

    The Client is for, whatever reason attempting to connect to 127.0.0.1
    For this reason, when I run the client on the same machine as the host, it can of course connect and operate, but as soon as I put the client on any other machine, aka my brother's computer, (on the same network) or my laptop at my friend's house (a separate network) it fails both times, since 127.0.0.1 merely points back to localhost, aka the current device.

    I am trying to find anywhere within the Photon Settings which I may be able to change the IP other than in the PhotonSettings file, as that file, has the correct IP address.
  • One question in general: Is this PUN Classic or PUN 2?

    While taking a look at it, I ran into a similar issues as you have originally posted, but with the difference, that the error message always stated the correct IP (used different addresses to test). What I have done wrong in my test was setting the connection protocol properly: there was 'TCP' selected in my PhotonServerSettings, but I have tried to use the port for UDP connections. I'm asking you to check this, too. If you want to use a TCP connection, you have to connect to port 4530 (UDP would be 5055). Also recheck the PhotonServerSettings.

    If this is all set up correctly, but still doesn't work, you can add the void OnFailedToConnectToPhoton(DisconnectCause cause) callback (PUN Classic) or the override void OnDisconnected(DisconnectCause cause) callback (PUN 2). Afterwards you can check the DisconnectCause and see if this gives you any further insights.