In a local environment I have some Android devices that are connected with a web socket in the foreground service. This socket connection only listens for messages and pushes them to the push notification. Sometimes you may not receive messages for hours or sometimes days, so this needs to be really stable.
The push notificationworks when the screen is on when the goes in lock mode, the connection is fine for the first few minutes. If a message is pushed after 10-15 minutes, the notification message will not be displayed. As soon as another message comes up, the previous message is suddenly picked up and displayed to. After 60 minutes or more, no messages will be displayed at all. It appears that the connection is no longer intact and the server and app logs do not show that the connection is lost.
I have been working on this for more than 4 intensive days, but to my frustration this did not work. I have found many topics related to this topic, the optimization for the app turned off, send a ping every minute (StayAlive) to the server but all to no avail.
Are there alternative options for establishing a stable connection with the server via foreground service?
Please let me know.
Thank you in advance.