Socket connection in background
Socket connection in background I need to make an application where, while the user is authorized, it keeps the socket connection until it is logged out. For this purpose, a foreground service is created, which starts after the authorization of the user, and stops when it is logged out. It implements connection and reconnection on the socket. All works well until you press the power button and turn off the charging. After this, the user stops receiving pongs from the server and the SocketTimeoutException is received on the OkHttp, and also stops receiving messages on the socket. On JavaWebsocket The connection was closed because the other endpoint did not respond with a pong in time. is received, after which you can successfully create a new socket connection, but it will repeat the same problem in the loop. In the settings, the optimization of the battery for this application was disabled. What can I do to make a stable connection socket work in the background? Implementation of acti...