Stuck at ConnectingToNameServer

I haven't had this issue before but after introducing regional switching in-game, this has been occurring more recently. Can anyone give me an idea why this is happening? Player join flow is as is:

Player start app -> Player authenticate with our third-party database -> Player gets a string representing a region -> player sets their photon server setting to that region -> Connects to Photon cloud via PhotonNetwork.ConnectUsingSettings

Before using regions, we were simply connecting using the above method. So we just added two extra steps regarding region saving and now we get stuck at that ConnectingToNameServer phase 1 out of every 7 or so app starts.

Comments

  • Hi @AndyWasHere,

    since you are mentioning that this happens just occasionally, can you confirm that this isn't a problem with your connection? Can you say if this happens on different regions or does it happen always on the same region?

    If you haven't done this already I'm asking you to add the OnFailedToConnectToPhoton(DisconnectCause cause) callback and see, if this gives you further information why the connection isn't working.
  • Yes, I can confirm it isn't a problem with connection, since I would stop and restart the editor immediately and it connects without a hitch.

    It doesn't seem to matter which region, from what I've tested. I'm mainly testing in both US East/West. I haven't had an issue with those regions before this region switching implementation (was mainly testing in US West at the beginning).

    Sure thing, I'll try to replicate it ASAP and post the results here.
  • edited July 10
    Update: So I was finally able to replicate it and have it stuck in ConnectingToNameServer phase. There was no failure for that callback to occur. I left it running for 4+ minutes and it's stuck in that connection phase as I've stated in thread title.

    PUN Version: 1.87
  • Hi @AndyWasHere,

    Could you update to latest PUN version 1.91 and see if the issue persists?
  • edited July 11
    Apologies, we have Photon Voice and that has its own PUN, of which it is version 1.87. That asset system is rather confusing. When will Voice be updating to that of PUN standalone version? We can't afford to wait on an update.

    Also, in the case that this problem does persist, what other steps can I take to remedy this issue? Consistently whenever the problem occurs, it stays stuck at that phase and does nothing else. Should I try a disconnect if it attempts connecting for too long and reconnect?

    Thanks,
    Andy
  • @AndyWasHere

    FYI: We released Photon Voice 1.16 today (might take some time before it appears on the store while it's being reviewed) which includes PUN 1.91v.
  • edited July 12
    Awesome, we'll keep an eye out for it.

    Also, another thing about this issue: if I try to disconnect via PhotonNetwork.Disconnect while in ConnectingToNameServer, it gets stuck in Disconnecting phase and doesn't go to PeerCreated. Attempt to connect again via settings yields the same result of original issue.
  • edited July 12
    We updated Photon Voice to 1.16. The problem persists, unfortunately.

    Edit:

    Tried using PhotonNetwork.ConnectToBestCloudServer as well. Just a straight connect on void Start(). It gives the same issue. I also get no callbacks from override OnConnectedToPhoton().

    While stuck in that phase, I tried disconnection via removing my ethernet cord. It shoots me back into PeerCreated phase. I plug it back in, and attempt to reconnect. I get the same result of original issue. Without closing the app, I redo this a few times, and same conclusion every time. This seems like per app "instance" of a connection. If I restart the editor, it goes back to normal. But the issue seems to be occurring more often since updating to 1.91v.

    So for above, I'm either using PhotonNetwork.ConnectToBestCloudServer incorrectly or it is bugged, but it always gets stuck in ConnectedToNameServer phase, which is different from my original issue.
  • edited July 12
    Anyway, PhotonNetwork.ConnectViaSettings is my primary method to connect to Cloud, and I had one or two instances where it occurred with the 1.91v. This isn't ideal considering I still haven't an idea of the cause of the problem, and our game is currently out in public.

    Using PhotonNetwork.ConnectViaSettings, I was in the phase again. With the same method above of pulling the ethernet cord (no wireless capability), it stays in ConnectingToNameServer, surprisingly. Continuing with experiment with ethernet cord unplugged, I tried changing regions to force a disconnect. Again, it stays in Disconnecting. Plugging the ethernet cord back in, thereby having connection again, I tried reconnecting and it still doesn't work. Tried disconnecting with a keyboard shortcut a couple times, I get this warning message: "Can't execute Disconnect() while not connected. Nothing changed. State: Disconnecting".

    It seems like PhotonNetwork.ConnectViaSettings failed, but doesn't give me accurate information (debugged that method initially, it tells me True when this problem occurs before all my experimenting) and I'm actually not connected at all? So something in the PeerCreated phase, something went awry? This is all speculation on my end at this point. I'm not really sure what else to do with any of the method calls Photon is providing when none of them will connect me to Cloud server and there doesn't seem to be any way to "refresh" the connection while in-app. Closing/opening the app is so far the only solution which is really bad.
  • edited July 13
    @JohnTube
    @Christian_Simon

    I think I found what the problem is. When exiting the app, photon does an auto-disconnect. However, when immediately re-opening the app/starting the editor, I guess it lands the user on the same connection line, so to speak. This only occurs if the user was in a room while exiting app. This seems to cause the issue, or at least highly related to it. I've been able to replicate it somewhat consistently now. However, I still run into the same issue of being unable to disconnect or reconnect in game.

    Any insights would be appreciated. If I can't disconnect or attempt another connection to Cloud, what other methods can I try while in-game without having to restart the app? Is there some sort of Photon.Refresh or reset that I can try so that I can force the client into PeerCreated state?
  • Bump.

    Re: Any insights would be appreciated. If I can't disconnect or attempt another connection to Cloud, what other methods can I try while in-game without having to restart the app? Is there some sort of Photon.Refresh or reset that I can try so that I can force the client into PeerCreated state?

    Just want advice. Thanks!
  • When exiting the app, photon does an auto-disconnect. However, when immediately re-opening the app/starting the editor, I guess it lands the user on the same connection line, so to speak.


    When exiting the app, all used system resources should get freed. When starting the app again, it should use new system resources and don't rely on previously allocated system resources. Maybe I'm wrong, but I don't think that this is a problem.

    Any insights would be appreciated. If I can't disconnect or attempt another connection to Cloud, what other methods can I try while in-game without having to restart the app? Is there some sort of Photon.Refresh or reset that I can try so that I can force the client into PeerCreated state?


    When you call PhotonNetwork.Disconnect() the PeerState should get set to PeerCreated. In this case you can usually connect to Photon again. If the PeerState doesn't get set properly, you can try to set it on your own.

    I'm going to run a few tests today and try to reproduce this issue. Is there any chance that you can share a repro case with us?
  • edited July 17

    When you call PhotonNetwork.Disconnect() the PeerState should get set to PeerCreated. In this case you can usually connect to Photon again. If the PeerState doesn't get set properly, you can try to set it on your own.
    How can I set it manually? The stateConnection and detailedStateConnection enums are read-only. Is this something I'll have to internally change Photon?

    What would go into the repro case?

  • What would go into the repro case?
    A minimal project or shortest list of steps that lead to the 100% chance of reproduction of the issue.
  • edited July 18
    Unfortunately as I've been typing out above, it's not 100% reproduction. It's still inconsistent in that I can't replicate the issue every time.

    The shortest steps are using the method PhotonNetwork.ConnectViaSettings, create a room, stop playing the editor, immediately replay, and maybe 1 out of 7 times it'll do it.

    I don't know what else to tell you when I've been very descriptive of the process above. There isn't anything to debug when nothing happens after PhotonNetwork.ConnectViaSettings, nor is there anything I'm doing with Photon prior to the method call.

    The fact that I tried using PhotonNetwork.Disconnect and it stays in Disconnecting state rather than usually going into PeerClient state, is that not enough info to pinpoint a particular issue with Photon? I wouldn't know any internal conditions to have Photon behave like that.

    I know you guys are busy and get a bunch of questions to resolve, but at least answer this: how can I manually set PeerState to PeerCreated, as @Christian_Simon mentioned? My team paid for Photon+ version, I'd appreciate any insight regarding this.
  • So I just tried PhotonNetwork.networkingPeer.State = ClientState.PeerCreated, and then attempted a ConnectViaSetting. Still the same issue.
  • The shortest steps are using the method PhotonNetwork.ConnectViaSettings, create a room, stop playing the editor, immediately replay, and maybe 1 out of 7 times it'll do it.


    I can't reproduce the issue. Tried several times as described above, but I'm ending up joining a room every time and don't get stuck.

    So I just tried PhotonNetwork.networkingPeer.State = ClientState.PeerCreated, and then attempted a ConnectViaSetting. Still the same issue.


    When did you call it? Right before trying to connect? Besides that it should work if the client is disconnected and something shouldn't get reset properly. But after restarting the Editor's playmode, all settings should be reset to default values anyway. So this might be an option to use, if you try to connect for a second time when the game is running. However I'm pretty sure that you won't have to this manually.

    Since we haven't asked, which version of Unity do you currently use? Is it a stable release or a beta version? If it is a version beginning with 2017, which Scripting Runtime Version are you using? Is it .NET 3.5 or .NET 4.x? You can check this in the Player Settings > Other Settings. By default this targets .NET 3.5 which should work fine (this might not be the case for .NET 4.x). Additionally which Scripting Backend to you use? Is it Mono or IL2CPP? You can check this one next to the other option. By default this is Mono.

    From the original post:

    Player start app -> Player authenticate with our third-party database -> Player gets a string representing a region -> player sets their photon server setting to that region -> Connects to Photon cloud via PhotonNetwork.ConnectUsingSettings


    Can you confirm that the result from your 3rd party database is valid? If not, there should be at least one error message logged to the console. Since I'm not sure if we asked you about this: are there any warnings or errors logged to the console (or the log) when this issue occurs?
  • edited July 19

    When did you call it? Right before trying to connect? Besides that it should work if the client is disconnected and something shouldn't get reset properly. But after restarting the Editor's playmode, all settings should be reset to default values anyway. So this might be an option to use, if you try to connect for a second time when the game is running. However I'm pretty sure that you won't have to this manually.


    Upon app start, the state is PeerCreated. Then after ConnectViaSettings, it gets stuck and I call disconnect. That's when I attempt the manual setting. Unfortunately it just does the same thing. Right, I didn't think I should have to do this manually.


    Since we haven't asked, which version of Unity do you currently use? Is it a stable release or a beta version? If it is a version beginning with 2017, which Scripting Runtime Version are you using? Is it .NET 3.5 or .NET 4.x? You can check this in the Player Settings > Other Settings. By default this targets .NET 3.5 which should work fine (this might not be the case for .NET 4.x). Additionally which Scripting Backend to you use? Is it Mono or IL2CPP? You can check this one next to the other option. By default this is Mono.


    Unity 2018.1.2.1f
    Script runtime: .Net 3.5 Equivalent
    Script backend: Mono



    Can you confirm that the result from your 3rd party database is valid? If not, there should be at least one error message logged to the console. Since I'm not sure if we asked you about this: are there any warnings or errors logged to the console (or the log) when this issue occurs?


    Yes, I can confirm that our 3rd party database is valid and no errors or warnings regarding Photon or database.
  • Hi @AndyWasHere,

    Check out this discussion.
    Maybe you have the same issue as @Jakeco19.
Sign In or Register to comment.