[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [jetty-users] WebSocketGeneratorRFC6455.closeOut doesn't send reason when code < 0
|
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).
--
Developer advice, services and support
from the Jetty & CometD experts
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:
_outbound.addFrame((byte)FLAG_FIN,WebSocketConnectionRFC6455.OP_CLOSE,bytes,0,code>0?bytes.length:0);
Is this intended behavior? As a user, I expected that calling connection.close(-1, "reason for closure") would populate a _javascript_ ErrorEvent with:
wasClean: false
reason: "reason for closure"
Instead, reason is "". If this is intended behavior, I think the Javadoc needs some elaboration; it reads:
org.eclipse.jetty.websocket.WebSocket.Connection
public void close(int closeCode, String message)
Close the connection with specific closeCode and message.
Parameters:
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@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users