I am running a web server (NanoHTTPD) in an Android Service.
onStartCommand() returns the value from the overridden method in Service, so it should be "sticky".
However the service seems to stop, or at least the webserver stops responding. This happens mostly when the device has been inactive for a while, with the screen off. But also sometimes when it is seemingly running normally. The notification icon of the service keeps being displayed.
The device is not doing anything else, and it is plugged into power.
What can be done to keep the web server responding to requests? Or at least reduce the frequency of outages?