Not sure to be honest. It could be that Android closes the connection to conserve system resources? There might be some setting to tweak in the underlying Wslay library we use for websocket connections, but I haven’t found anything. Also, is it so bad to reconnect if the connection is lost?
There are some situations we must reconnect such as when internet connection lost but doing that after viewing admob rewarded video is kind of bad for me, because after reconnecting, the app must reload serveral stuff to sync with server state and in this case, reconnect, reload stuff, reward player for viewing ad is not what I’m expecting.
Actually I’m remaking my app. The app using react native not having this issue. I guess there must be settings for Activity or manifest to keep connection alive but I’m not familiar with native code.
Looks like currently dmSocket running on main thread (UI thread?) and when the thread put in background, paused… the socket connection is also dropped. If it’s the case, can we run it on a different thread or a background service?
I’m not sure what you mean with “dmSocket running on main thread”. It is a handle, it doesn’t run anything.
As for the connection, it’s done on a thread.
Also, not sure what using more threads would solve. All the app’s threads would be put to sleep in the background, not just the main thread.
So it’s not related to threads but it can be solved by background services. After some researches, I see someone can keep the connection alive when app put in background.
I propose youi open a ticket in the extension where you add any relevant information to help anyone implement it.
I’m not entirely convinced an android-only fix is ideal, as we have plenty of other platforms to support, and I’d preferably have a platform agnostic way .