Re: [w3c/ServiceWorker] Should EventSource and WebSocket be exposed in service workers? (#947)

> As far as I know, Chrome has supported WebSockets in ServiceWorkers for as long as it has supported ServiceWorkers.

I do not know this, there are a few previous versions (I can not remember for sure) tried to use WebSocket in the ServiceWorker script in Chrome and received an error.

I have two pages served by a ServiceWorker (localhost): **index.html** and **about.html**

Firefox opens the WebSocket connection and maintains it for only 30 seconds (+/-) ... before reaching this limit (?) if the user presses the **F5** key or if `window.location.reload()` is released page refreshes and there is no connection loss, it is as if the count would recommence. If you reach/pass this limit, the connection is closed silently without sending a "close frame" ... some time later the server reports **1006** (CLOSE_ABNORMAL).

In Firefox navigate between cached pages (within this "30-second" limit) it also produces the same ... the open connection on the previous page is closed silently without sending a "close frame".

In Chrome there is no time limit and browsing between different pages already cached does not end the connection.

I'm not sure which of the two implementations follows the pattern defined by the WebSocket API (Chrome or Firefox) ... I tried to find reference in [SPEC](https://html.spec.whatwg.org/multipage/web-sockets.html) but I think this does not concern WebSocket's spec but rather that of ServiceWorker.

I believe Firefox is closer to the ServiceWorker specification

> Note: ServiceWorkerGlobalScope object provides generic, event-driven, time-limited script execution contexts that run at an origin. Once successfully registered, a service worker is started, kept alive and killed by their relationship to events, not service worker clients. Any type of synchronous requests must not be initiated inside of a service worker.

[SPEC Reference](https://w3c.github.io/ServiceWorker/#serviceworkerglobalscope-interface)

Although I do not know if this is intentional since it is not sent a "close frame".

I found interesting persistence in the connection obtained in Chrome but, after all, which of these two distinct implementations is correct (or about to be correct)?



-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/w3c/ServiceWorker/issues/947#issuecomment-411277995

Received on Wednesday, 8 August 2018 04:07:05 UTC