DEV Community

Akira
Akira

Posted on

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.

Billboard image

Use Playwright to test. Use Playwright to monitor.

Join Vercel, CrowdStrike, and thousands of other teams that run end-to-end monitors on Checkly's programmable monitoring platform.

Get started now!

Top comments (0)

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay