Keeping User Active When Backgrounding App

Hello,

I am working on a small project that uses Relay and NGO for Android. When I want to send a room code to another user, I swipe out of the app and type it into text to send. This apparently will time out the connection and the code is no longer valid.

Is there any way to keep the connection alive/valid when operating outside the app? I would expect any end user would need this functionality. What are my options here?

Thanks in advance!

No and this has been reported a few times but I don‘t think Unity can do anything about that, this is just how mobile apps work. This kind of realtime networking as implemented by NGO is also rather unusual on mobiles. Actually I tend to believe NGO is primarily for desktop apps because of the way multitasking on mobiles is non cooperative.

Anyone please correct me if i am wrong but i don‘t see realtime networking working well on mobiles anytime in the near future. Has it ever been done by a realtime game where it doesn‘t have these issues?

Anyway, You would have to implement sending of a code or whatever in the app itself. Like sending an email. Any way that prevents you from leaving the app. Still, anyone at any time for any reason could put the app in the background, such as an incoming call, and that would end the client‘s session, or everyone‘s if this happens on the host device.

Thanks for the reply!

Good points, probably make the most sense to do it through a dedicated server anyways but I just wanted to see if anyone has approached this themselves.

Cheers.

Thank you for brining this to our attention, we discussed your use case and we are planning a possible improvement to change the timeout behaviour when a session is being setup to have a longer timeout from the time a host is bound to the time when the first player connects, we will aim to release this new improvement in Q1.

I have exactly the same problem

Do you have an estimate on this ?

Thank you rbitard for the follow-up, as mentioned in the above message we are aiming to release the improvement in Q1. I don’t have an exact date but I can assure you we are working on the above mentioned improvement

Hi @rbitard , FYI we’ve recently rolled out a new feature which increases the initial timeout from 10s to 60s. We are working to update our documentation to reflect this.

Did you change something or do I need to add some more code ? It worked flawlessly and after upgrading to unity6 I get a timeout after 60 secs if no one joins the lobby

This thread might be relevant to you: Relay connection failure after exactly one minute

Possibly something you use is deprecated now in Unity 6.