Hi,
First of all, something to keep in mind is that if you are starting the connection from a service worker, Chrome automatically terminates inactive service workers periodically. This includes service workers with an active WebSocket connection,
unless there is activity on those WebSockets. You can learn more about this here:
https://developer.chrome.com/docs/extensions/how-to/web-platform/websockets
Assuming that isn't the issue, even if the service worker is alive, it sounds expected that it would disconnect if the device goes to sleep.
You mentioned that you're attempting to use the power API but it isn't working. Is the problem that the device is going to sleep still, or that when you manually put the device to sleep the WebSocket connection is ended?