akka/akka-http

WebSocket server never send back close connection

Open

#1,358 opened on Aug 15, 2017

View on GitHub
 (6 comments) (0 reactions) (0 assignees)Scala (598 forks)batch import
1 - triagedhelp wantedt:docs

Repository metrics

Stars
 (1,311 stars)
PR merge metrics
 (Avg merge 1d 10h) (2 merged PRs in 30d)

Description

Hi, I found a problem that WebSocket server never send back WebSocket Close Connection when server output is infinite. Some WS libraries can't close connection because of this problem(At least SocketRocket and jetfire can't close connection).

I checked InfinitOutputServer.scala never send back Close connection and InfinitOutputServer.js do send back close connection using wireshark.

InfinitOutputServer.scala result is: screen shot 2017-08-15 at 18 45 23

And InfinitOutputServer.js result is: screen shot 2017-08-15 at 18 46 17

rfc6455 says:

If an endpoint receives a Close frame and did not previously send a Close frame, the endpoint MUST send a Close frame in response. (When sending a Close frame in response, the endpoint typically echos the status code it received.) It SHOULD do so as soon as practical. An endpoint MAY delay sending a Close frame until its current message is sent (for instance, if the majority of a fragmented message is already sent, an endpoint MAY send the remaining fragments before sending a Close frame). However, there is no guarantee that the endpoint that has already sent a Close frame will continue to process data.

I guess current behavior breaks RFC because of the endpoint MUST send a Close frame in response..

Problematic code is here

Contributor guide