Good feedback.

Curious, where did you see this isClean style of close behavior?

--
Joakim Erdfelt <[email protected]>
webtide.com <http://www.webtide.com/>
Developer advice, services and support
from the Jetty & CometD experts
eclipse.org/jetty - cometd.org



On Tue, Oct 30, 2012 at 3:31 PM, Brandon Mintern <[email protected]>wrote:

> Thanks for the explanations, guys. I changed the code to 4000 for
> errors and 1000 for successful exits, and everything is now working as
> I expected.
>
> 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
> range.
>
> Optionally, close(reason) could also be implemented as close(false,
> reason).
>
> Thoughts?
>
> On Tue, Oct 30, 2012 at 2:11 PM, Joakim Erdfelt <[email protected]>
> 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)
> > https://tools.ietf.org/html/rfc6455#section-5.5.1
> >
> > 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.
> > https://tools.ietf.org/html/rfc6455#section-7.4.1
> >
> > Some status codes are not allowed to be sent over the network. (They
> essentially are internal status codes).
> >
> > --
> > Joakim Erdfelt <[email protected]>
> > webtide.com
> > 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 <[email protected]>
> 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
> >> [email protected]
> >> https://dev.eclipse.org/mailman/listinfo/jetty-users
> >>
> >
> >
> > _______________________________________________
> > jetty-users mailing list
> > [email protected]
> > https://dev.eclipse.org/mailman/listinfo/jetty-users
> >
> _______________________________________________
> jetty-users mailing list
> [email protected]
> https://dev.eclipse.org/mailman/listinfo/jetty-users
>
_______________________________________________
jetty-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/jetty-users

Reply via email to