I'm having some problems with my socket connection, I can leave the app running on background and go back in and everything works fine. When I open multiple apps to drain the device memory, my app and its service get killed and when I return to it everything gets recreated as expected. Nothing wrong so far. The problem arises when I DON'T do that, when I leave my app running on the background and just turn off the screen for a long period of time (15 minutes). I have a live socket connection living on a service that apparently gets "disconneted". The service itself does NOT get killed. I'm sure of that, but the connection stops responding some how.
I'm suspicions that deep sleep is to blame for two reasons. 1. This never happens on the emulator. 2. This never happens on my device when plugged in via USB.
I might be wrong, but I'd like to know how this work. I cound't find much documentation about this. I would like a way to know when the device is about to enter sleep mode so I can kill the service myself (so when it gets recreated also will the socket)
I'm using firebase btw. :)