Handling disconnects due to application pause or debugger

Options
I am using PUN in a fairly simple way to replicate data between a pair of clients.

The session is being established using ConnectUsingSettings followed by JoinOrCreateRoom called from OnJoinedLobby.

At the moment I'm testing the system on Windows and Android.

When one of the clients is running on Android, and that client is paused (goes into background) the client pretty much always gets booted out of the session. How am I best to manage re-joining when the player unpauses? Is there any way to make it less likely to get booted?

Secondly, when I am using the PC and attempting to debug my application, once I've stopped the application with a breakpoint, the app will lose it's connection the next frame. Is there any way to prevent this or handle it better?

Thanks

Jules

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited July 2016
    Options
    Hi @jules43,

    Let's separate the 2 issues:
    1. My colleague Tobias explains how to set background thread timeout in this post. You may also increase player TTL and handle rejoin when application goes back to foreground.
    2. For debugging purposes we recommend using local Photon Server for development if that's possible and follow this little debugging guide.
  • jules43
    Options
    1. Background thread timeout

    To confirm: PhotonNetwork.BackgroundTimeout = {value} can be used to control how long it hangs about in background. If it disconnects after that then when I unpause I should attempt to re-establish connection. I can presumably hook something like OnDisconnectFromServer or similar.

    2. Debugging

    The debugging guide is very clear, that's very helpful.

    Thank-you.
  • jules43
    Options
    I've been working on setting up the debugging as suggested:

    I downloaded PhotonServer 4 to my machine and run up the PhotonControl app. Then started the LoadBalancing client and set the game ip address to local.

    I then ran the LoadBalancing TestClient and that seems to work fine.

    In my application before calling PhotonNetwork.ConnectUsingSettings I added the following:

    PhotonNetwork.PhotonServerSettings.HostType = ServerSettings.HostingOption.SelfHosted; PhotonNetwork.PhotonServerSettings.Protocol = ConnectionProtocol.Tcp; PhotonNetwork.PhotonServerSettings.ServerAddress = Network.player.ipAddress; PhotonNetwork.MaxResendsBeforeDisconnect = 8; PhotonNetwork.networkingPeer.DisconnectTimeout = 30; PhotonNetwork.networkingPeer.SentCountAllowance = 8;

    This yielded the message:
    Connect() to "192.168.1.77" failed: System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it.

    So I updated my firewall settings to open port 4530 and instead got the message:
    Receiving failed. SocketException: TimedOut


    I noticed that the load balancing client test client used port 5055 so I tried overriding the port to this and got the same result.

    I presume this is a config problem, I'm using the one that is in the Photon-OnPremise-Server-SDK_v4-0-29-11263 download with the timeout values set to 0.

    Any help getting my Unity program to connect to the local server would be greatly appreciated.

    Thanks

    Jules
  • emrahsungu
    Options
    for your on premise setup
    1) have you setup your config files correctly?
  • emrahsungu
    Options
    for your on premise setup, you should setup your config files. if i remember correctly, you should setup the listener ports and master server to game server udp and tcp ports
  • jules43
    Options
    In my PhotonServer.config in the LoadBalancing section I have the following:
    <!-- 0.0.0.0 opens listeners on all available IPs. Machines with multiple IPs should define the correct one here. -->		
    <TCPListeners>
    	<!-- TCP listener for Game clients on Master application -->
    	<TCPListener
    		IPAddress="0.0.0.0"
    		Port="4530"
    		OverrideApplication="Master"
    		PolicyFile="Policy\assets\socket-policy.xml"
    		InactivityTimeout="10000"
    		>
    	</TCPListener>
    		
    	<TCPListener
    		IPAddress="0.0.0.0"
    		Port="4531"
    		OverrideApplication="Game"
    		PolicyFile="Policy\assets\socket-policy.xml"
    		InactivityTimeout="10000">
    	</TCPListener>
    			
    	<!-- DON'T EDIT THIS. TCP listener for GameServers on Master application -->
    	<TCPListener
    		IPAddress="0.0.0.0"
    		Port="4520">
    	</TCPListener>
    </TCPListeners>
    
    As I understand it setting the IPAddress to 0.0.0.0 means it will accept any listener, and the OverrideApplication="Master" means that I don't need to control the game name I'm looking for.

    I'm connecting using TCP to 127.0.0.1 (localhost) at the moment with port 4530, but I've also tried the local IP machine IP address. In PhotonControl I have the load balancing server game ip address set to 127.0.0.1 and the LoadBalancing app started.

    Any suggestions as to what I need to change in my server configuration to have PUN and PUN Voice work as they do with the cloud hosted service?

    Thanks

    Jules