MozillaZine

[WebSocket] Echo back a Closeframe by a client

User Help for Mozilla Firefox
riyafa
New Member
 
Posts: 1
Joined: July 10th, 2018, 10:17 pm

Post Posted July 10th, 2018, 10:21 pm

Hi

According to the WebSocket spec:

If an endpoint receives a Close frame and did not previously send a Close frame, the endpoint MUST send a Close frame in response.


I wrote a server that initiates connection close by sending a close frame and then it awaits for an echoed back close frame from the client and then closes the TCP connection.

I used firefox and chrome javascript client to test this behavior:

Code: Select all
//make connection
var ws = new WebSocket("ws://localhost:9090/basic/ws", "xml", "my-protocol");
ws.onclose = function(frame) {console.log(frame)};
//ask server to close connection
ws.send("closeMe");


The issue is that both the firefox and chrome clients do not echo back a close frame to my server when the server initiates the close by sending the close frame(I can see this close frame logged in the console).

I don't think both firefox and chrome javascript clients are violating WebSocket protocol. Can anyone explain why server does not receive the echoed close frame when it initiates close? Is there any issue with the javascript code?
Stackoverflow issue: https://stackoverflow.com/questions/512 ... ates-close

Thank,
Riyafa

Return to Firefox Support


Who is online

Users browsing this forum: Google [Bot] and 14 guests