Disconnected transport after sleeping

Hello, I made an online game for Android with transport, but when I don’t use the phone for a while or when I go to rest mode, the connection is disconnected and the application stops working, what is the reason?

From the information you provided, it could be one of two things:

  • The connection was closed due to inactivity. If we don’t hear anything from the remote peer for a while, the connection gets closed. By default this is 30 seconds. Check this question in the FAQ about modifying this timeout. The next question also deals with finding the reason the connection was closed, which could be useful in confirming what the issue is.
  • After a while, both iOS and Android will eventually free up the resources of a backgrounded app. This can include closing its sockets. Obviously once a socket is closed communications are not possible anymore. We have code in place to attempt to recreate UDP sockets, but if you’re using WebSockets that won’t work.