6

Both SSE (Server Sent events) and Websockets allow real-time messaging from a server to a client.

Do these stream protocol work when the browser is in the background and another programs are in focus, especially in mobile browsers?

Adam Matan
  • 128,757
  • 147
  • 397
  • 562

2 Answers2

3

Yes. At least WebSocket.

Open this demo in browser 1, click on "open 2nd instance", copy the link to browser 2, put browser 1 to background and click "publish" in browser 2.

The demo will work on Chrome for Mobile (on Android) also. I have just tested: it'll receive messages a) when switching to another tab, and then switch back, and also b) if you open another activity (app), and then return to Chrome.

You can also try the other demos. Other than audio output with the "beatbox demo", everything will work on Chrome Mobile. Note that with the "beatbox demo", you can still use the smartphone as a controller .. it's just the audio output which has issues.

Disclaimer: I am original author of Crossbar.io and work for Tavendo.

oberstet
  • 21,353
  • 10
  • 64
  • 97
  • +1 Thanks a lot! Does regular Websockets - not using crossbar.io - work in the background? Does the behaviour vary between browsers? – Adam Matan Mar 19 '14 at 14:16
  • Yes, the described behavior is also working with pure WebSocket. And yes, Crossbar.io is open-source (https://github.com/crossbario/crossbar). Regarding browsers: tested (and works) with Chrome/FF/IE11 desktop and Chrome for Mobile. – oberstet Mar 19 '14 at 15:13
  • I did not test other browsers .. so there might be issues lurking. But I guess at least FF Mobile and Safari (both desktop and mobile) should work similar. But better test it .. – oberstet Mar 19 '14 at 15:15
1

Not on all platforms. According to Keep WebSocket alive in Mobile Safari it is not possible in mobile safari.

Community
  • 1
  • 1
Ryan Harmuth
  • 345
  • 2
  • 10