Client WebSocket disconnects when browser is minimized or not in focus - Chrome

[Deleted User]
[Deleted User] Posts: 25
edited April 2021 in Tips and Tricks #1

Here's a tip for anyone using websockets and chrome to establish a connection to their PubSub+ broker.

The issue:

You might be experiencing websocket disconnects after 5-6 minutes of your chrome browser being minimized or out in focus. The session disconnects with the message "Connection closed: 1001 Going Away (The endpoint is going away due to a server failure or client navigation), clean closure: true"

The cause:

In July 2020, a Chrome feature intended to save battery life was introduced. "Intensive throttling of Javascript timer wake ups" throttles at a 1-minute (60 second) interval. See here for more info:

This conflicts with the default web-transport inactive-timeout setting that is set to 30s on client profiles.

When the Javascript timer is throttled at a 1-minute interval, the web client will be unable to send keepalive messages to your broker within the default 30s inactivity timeout. To avoid the issue, either disable the feature "Intensive throttling of Javascript timer wake ups" in Chrome or change the inactivity-timeout to a value more than 60s.

The fix:

To avoid the issue, either
1. disable the feature "Intensive throttling of Javascript timer wake ups" in Chrome or,
2. change the web-transport inactive-timeout in the client profile to more than 60 seconds.

To disable the Chrome feature, key in "chrome://flags" in Chrome URL field, search for "Throttle Javascript timer" and disable the feature.


  • Aaron
    Aaron Member, Administrator, Moderator, Employee Posts: 541 admin

    I actually didn't know this! It explains why my JavaScript bus demo disconnects a lot more frequently now, vs. a couple years ago if I'm away from that Chrome tab. I've updated theweb-transport inactive-timeout in my client-profile to 75 seconds and it totally fixed the issue! 👍