|Re: [jetty-users] WebSocketGeneratorRFC6455.closeOut doesn't send reason when code < 0|
Thanks for the explanations, guys. I changed the code to 4000 for
errors and 1000 for successful exits, and everything is now working as
It looks like jetty-9's WebSocketSession provides the same close() and
close(code, message) methods? While these work well enough if you're
familiar with the RFC, I think it would be nice to provide a
close(boolean isClean, String reason) method. Then, internally, this
would call either close(1000, reason) or close(UNKNOWN_ERROR, reason),
where UNKNOWN_ERROR is 4000, 4999, some other 4xxx, or a special
JETTY_UNKNOWN_ERROR close code registered with IANA in the 3000-3999
Optionally, close(reason) could also be implemented as close(false, reason).
On Tue, Oct 30, 2012 at 2:11 PM, Joakim Erdfelt <joakim@xxxxxxxxxxx> wrote:
> Quick answer, if you want a reason message, you have to specify a valid, can be sent over the wire, close status code.
> Detail answer,
> The WebSocket spec (RFC 6455, Section 5.5.1. Close)
> A Close frame MAY contain a body.
> If there is a body, the first two bytes of the body MUST be a 2-byte unsigned integer representing the status code.
> Following the 2-byte integer, the body MAY contain UTF-8 encoded data with reason.
> And the status codes allowed to be sent over the wire are in Section 7.4.1.
> Some status codes are not allowed to be sent over the network. (They essentially are internal status codes).
> Joakim Erdfelt <joakim@xxxxxxxxxxx>
> Developer advice, services and support
> from the Jetty & CometD experts
> eclipse.org/jetty - cometd.org
> On Tue, Oct 30, 2012 at 1:22 PM, Brandon Mintern <mintern@xxxxxxxxxxx> wrote:
>> When a connection is closed with a message and closeCode <= 0, the message is not sent at all. This is because of the test in line 382 of WebSocketGeneratorRFC6455.java:
>> wasClean: false
>> reason: "reason for closure"
>> Instead, reason is "". If this is intended behavior, I think the Javadoc needs some elaboration; it reads:
>> public void close(int closeCode, String message)
>> Close the connection with specific closeCode and message.
>> closeCode - The close code to send, or -1 for no close code
>> message - The message to send or null for no message
>> As implemented, message is never sent unless closeCode > 0.
>> jetty-users mailing list
> jetty-users mailing list
jetty-users mailing list
Back to the top