Skip to main content

[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

Thanks for the quick response. I was just looking at that spec, but in this case, the WebSocket.Connection documentation specifically says to use -1 to indicate "no close code". I assumed that this would generate a successful close with the given message, that I need not understand the various close codes. If that is not the case, why is -1 mentioned in the docs at all?

What is Jetty's recommended method for closing a connection successfully with some kind of message? I assume:

connection.close(1000, message)

would do the trick, but it seems strange to me that it's not better abstracted away from the user of WebSocket.

On Tue, Oct 30, 2012 at 1:29 PM, Jesse McConnell <jesse.mcconnell@xxxxxxxxx> wrote:
http://tools.ietf.org/html/rfc6455#section-7.4

afaik -1 is not a valid close code, and only valid close codes can have a reason

cheers,
jesse

--
jesse mcconnell
jesse.mcconnell@xxxxxxxxx


On Tue, Oct 30, 2012 at 3: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
>
_______________________________________________
jetty-users mailing list
jetty-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/jetty-users


Back to the top