Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincent15000's avatar

Websocket disconnected if the application / the browser is put in background

Hello,

I have a problem with a Laravel / VueJS application for which the websocket connexion (with soketi and Pusher) disconnects when the application / the browser is put in background (for example when I use a tablet and I work on another software, so that the browser is in background for some time) and I need to refresh the page to see the page updated if I go back to the browser.

Furthermore I need to check every second if the connection with the back is up or down to display a message on the screen for the case if the connexion is down (due to session expiration, due to WiFi disconnection, due to network problem, ...).

It's a real time application, so if I'm not sure that the data are up to date, I need to inform the user with a popup message.

So I want to not have to refresh manually the webpage and that it's done automatically.

What solution do you suggest me ?

Thanks for your help.

V

0 likes
1 reply
vincent15000's avatar

Here are solutions suggested by ChatGPT.

  • WebSockets avec Laravel Echo et Pusher
  • Ping/Heartbeat Mechanism
  • Service Workers
  • Background Tasks avec Web Workers
  • Browser Events (Online/Offline Events)
  • Axios Interceptors
  • Session Expiration Monitoring
  • Application State Watchers
  • Network Information API

Please or to participate in this conversation.