JJJ
JJJ

Reputation: 2909

Closing or referencing the websocket from chrome dev console?

I'm trying to break my own app that is using socket.io by opening up a socket and sending data to it through the dev console.

I see the web socket open under the network tab, and can see the data it's sending and receiving, however, I cannot right click and grab the reference to send more data, which is fine...

Next thing I tried, was to open up another socket, point it to the same IP/port and try using the same session ID, but that only automatically closes the socket since there is already a socket open for that session ID.

Is there a way to close the open socket, open up one with the same session ID, and send messages through the dev console? Or is there any other way someone can mess with the socket through the dev console?

Upvotes: 0

Views: 962

Answers (1)

jfriend00
jfriend00

Reputation: 708056

You can set a breakpoint in some scope of the page Javascript that has access to the webSocket object. It will take some understanding/study of the page's Javascript code to determine where this breakpoint should be set. Then, run the code that hits the breakpoint. While sitting at that breakpoint with access to the webSocket object, you can then execute methods on that object to send data over it.

Upvotes: 1

Related Questions