Suddenly Disconnecting from the Error

0 votes

I am working with the S2 server, and Player is suddenly disconnected. 

So can you let me know how would I solve this issue. Please see the Image for better explanation.

ScreenShot

 

Thank you

 

asked Apr 4, 2014 in AppWarpS2 by marine.modi (62 points)

1 Answer

0 votes
I was able to reproduce the problem. It happens when the app loses focus. This causes the Update loop to pause and so the application misses keep-alives from the server.

You can try this out to stop the app from pausing when it loses focus by Edit-->Project Settings-->Player-->Resolution and Presentation-->Run In Backgound
answered Apr 5, 2014 by dhruvc (1,099 points)
Ok Dhruv. I've tested it, but I am working for mobile dev. using unity. Well, Now when I minimize the app the player is being disconnected from the lobby. Can you let know what would be a problem for that ? Also I've tried Application.runInBackground = true;
That is going to be OS dependent behavior. I know that when an app goes in the background iOS terminates its TCP connections (unless its a VoIP app). Android I'm not sure if it will do it immediately - but it also terminates the TCP connection if the app spends time in the background.

The runInBackground is useful for desktop builds. For mobile, you will have to handle such cases in the application.
Ok. I do understand this case. I've also tested with the appwarp cloud but the appwarp cloud doesn't disconnect for many min. Is it because we are using the S2 server? Your suggestion would extremely help me. Also my other friend asked me to work with UDP if TCP is disconnected.
Are you doing this test using the mobile SDK or the desktop? From your screenshot it looked like a desktop. The desktop SDK - as long as you set the runInBackground flag, you should be fine. Can you confirm if by setting this flag your issue is no longer there.

Your connection loss is only on mobile when the game goes in background correct?
@dhruv. I am using both of them, First user is connected with unity and second one is connected by iDevice. Yet the issue is prevailing, and the screenshot is taken from the unity editor which gives information about the user leaving the room.
The following is the summary (both appwarp cloud and appwarp s2)

For desktop -> set the Application.runInBackground flag and it should be fine. Let me know if this is not the case for you on desktop.

For Mobile -> Connection error is expected when in background. App needs to handle it by reconnecting.
Okay. Will do the same :)
Hi,
We've updated the Unity SDK on our site which will remove the dependency on you requiring to set the runInBackground flag. Please download it and update your app and let us know if you face any issues.
Hi, Thank you dhruv for passing this valuable information. I would download and let you know if further issue comes with me. Highly Appreciate this help.
Hi Dhruv, I am still facing the same issue. Could you please check again?
You also need to update the server side SDK (AppWarpS2.jar) - download the latest from our site. Sorry I forgot to mention in my earlier response.
Okay Dhruv. I've updated the latest jar files as well as the Unity dlls but still the game is being disconnected.
Followed up offline on this, the issue is resolved after using the latest binaries. However intermittent connection issues will happen when targeting mobile devices for the following reasons

1) User locks the phone or presses the home screen to put the app in background
2) The device looses its 3G/cellular connectivity or switches between WiFi/Cellular sources.

The way to handle this is to have the application connect again automatically or ask the user to manually connect to multiplayer once it has internet connectivity.

You can also look in to the connection resiliency feature.
http://appwarps2.shephertz.com/dev-center/connection-resiliency/
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...