Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Firefox/Chrome devtools Is there a way to send/edit websocket messages after connection

I have a Safari/Firefox/Chrome browser. My browser has devtools. Is there a way to happy send/edit websocket messages for existing connection? Or by plugin?

Thank you

like image 337
Irina Avatar asked Dec 09 '19 03:12

Irina


1 Answers

You can grab instance of websocket connection and can use it further to send further messages on it.

Grab socket connection isntance

You must be aware of websocket connection establishment as below:

websocket = new WebSocket('your-ws-url-goes-here');

Now you can use instance of websocket and can use .send() and .close().

Your question states that you want to use existing connected web socket, you can look for socket connection instance in source code and can use it for sending further messages.

Example to play with

You can play with websocket and its instance here at http://websocket.org/echo.html

Notice here

var wsUri = "wss://echo.websocket.org/";

and function having

websocket = new WebSocket(wsUri);

You so you know websocket is connected and having instance in websocket

You can open devtool and type websocket to see all of the option. So in your case you need to find instance of connection so you can play with it.

About editing existing message

I couldn't find if there is any way to edit sent messages, and i think it should not be there. You can send new message since earlier message must have been responded already.

like image 85
Dheeraj Thedijje Avatar answered Oct 02 '22 16:10

Dheeraj Thedijje