Chrome - Disabling Web Sockets or Closing a Web Socket Connection?

Google ChromeGoogle Chrome-Devtools

Google Chrome Problem Overview


Is there any way to disable web socket connections or end a web socket connection through Chrome's developer tools network tab?

I've noticed that turning throttling under the network tab to Offline doesn't affect web socket connections that have already been established. It only prevents traditional HTTP requests from going out.

There's a question here related to this, but it's woefully outdated.

Google Chrome Solutions


Solution 1 - Google Chrome

February 2022 update

As of Chrome 99 this is supported: https://developer.chrome.com/blog/new-in-devtools-99/#websocket

Original answer

No, there is no way to disable or close a connection from the Network panel. Source: DevTools Engineer.

If you have a reference to the WS connection, though, you can close it via the Console using its JS API.

Solution 2 - Google Chrome

You can close idle and flush your inactive socket pools in the Net Internals page in Chrome. However, this unfortunately only closes your active sockets by the looks of it.

chrome://net-internals/#sockets

Web Sockets

You would have to use the WebSockets API and call close() on a reference to an existing socket to close it explicitly. Otherwise, killing the process with the active socket is all I can think of.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionLloyd BanksView Question on Stackoverflow
Solution 1 - Google ChromeKayce BasquesView Answer on Stackoverflow
Solution 2 - Google ChromeGideon PyzerView Answer on Stackoverflow