Subject: [hybi] Clarification: only one onerror call per websocket?

From: Jason Duell <[email-masked]>
Date: Tue, 18 Oct 2011 15:01:58 -0700

Implementation detail:

Am I reading the spec correctly when I say that it implies that at most 
one "error" event should be dispatched per websocket?   I.e. if a user 
does something that requires the "fail the websocket connection" 
algorithm (like calling close() before the ws connection has been 
established), and the server *also* replies with a non-101 status code, 
we should only call onerror once.

My read is that both of these actions "fail" the ws, but that the "close 
the ws" algorithm only sends out one error msg (if the ws failed or was 
closed w/prejudice).

Jason Duell
Mozilla

---

From: Bjoern Hoehrmann <[email-masked]>
Date: Wed, 19 Oct 2011 00:37:13 +0200

>we should only call onerror once.

This seems to be a question for the W3C API specification, comments on
which should be sent to <[email-masked]>. It seems there is only
one point from where error events might be dispatched in the algorithm,
you just have to check that "the WebSocket connection is closed" happens
only once. This happens "When the underlying TCP connection is closed"
and "If the WebSocket connection could not be established". I'd think it
is obvious that you can determine either only once without additional
attempts to establish a new connection and it seems fair to assume they
are mutually exclusive, but I have not tried to debug all the relevant
specifications in their entirety to reverse-engineer a complete answer.

I note in passing that the API proposal says "decoded as UTF-8, with
error handling" without defining what that means as far as I could find.
This may mean that clients should recover from errors in the "reason"
phrase, which might go against the Working Group's decision to treat
encoding errors as fatal errors. I also note the "review period" ends
this week. While that has no formal consequences, people might want to
make sure they submit their comments very soon if they have any.
-- 
Björn Höhrmann · mailto:[email-masked] · http://bjoern.hoehrmann.de
Am Badedeich 7 · Telefon: +49(0)160/4415681 · http://www.bjoernsworld.de
25899 Dagebüll · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/