WebSocket Error – Connection is already closed.

Datetime:2016-08-22 22:29:55         Topic: WebSocket  Test Engineer          Share        Original >>
Here to See The Original Article!!!

While trying to send a WebSocket transaction, I hit the following error

Connection is already closed.

I received this error when working on an application that involved a WebSocket connection. The Websocket handshake between the client and server was successful. After that I was able to send data to server using ws.send(“request_data_1”). I had no trouble receiving the data using ws.recv(). But when I sent the next frame of data using ws.send(“request_data_2”), I got the Connection is already closed and socket is already closed error message. I couldn’t figure out why exactly the connection was getting closed.

After some research, I figured out that the server was expecting data in JSON format. I transformed the data being sent to json

format and things started working smoothly.


When looking up this error online, I noticed Google was not very helpful. So I thought I would write this short post to help anyone else who stumbled across this error. Hope this helped!

Avinash Shetty

I am a software tester with over 9 years of experience in software testing. Currently I am working at Qxf2 Services Bangalore. As a student of the context-driven approach to software testing I feel there is a lot to learn out there which keeps me very excited. My work has helped me gain good experience in different areas of testing like CRM, Web, Mobile and Database testing. I have good knowledge of building test scripts using Automation tools like Selenium and Appium using Java and Python. Beside testing I am a “Sports Fanatic” and love watching and playing sports.

© 2016,Qxf2 Services. All rights reserved.


Put your ads here, just $200 per month.