Logo

dev-resources.site

for different kinds of informations.

How to disconnect WebSocket from Chrome Developer tool

Published at
11/13/2024
Categories
websocket
chrome
Author
Akira
Categories
2 categories in total
websocket
open
chrome
open
How to disconnect WebSocket from Chrome Developer tool

Sometimes, you may need to test how your application behaves when a WebSocket connection is disconnected. Here’s a step-by-step guide to disconnecting a WebSocket via the Chrome Console.

First, enter queryObjects(WebSocket) in the Chrome Console to retrieve the WebSocket object.

websocket object

Next, right-click on the WebSocket object, select Store as global variable from the modal that appears.

right-click modal

This action will store the WebSocket object in a temporary variable, typically named temp1.

variable which stores the websocket object

Finally, to close the WebSocket connection, use the command temp1.close(). This will disconnect the WebSocket, allowing you to observe your application’s response to the disconnection.

Featured ones: