Subject: Re: [hybi] Close Frame in the middle of a message

From: Takeshi Yoshino <[email-masked]>
Date: Thu, 5 Sep 2013 18:18:09 +0900

As Joakim said, the spec doesn't have any text to handle this edge case as
an error.

A server should send some appropriate close code (e.g. 1011 Internal
Endpoint Error) if it's going to terminate the WebSocket connection in the
middle of a data message, and then the peer client should check close code
to know there's a problem on the server. Not to prevent this, close codes
indicating an error should be passed as-is. No conversion (e.g. into 1006)
should happen.

About handling a non-error close code in the middle of a data message, I
agree with Zhong. It doesn't make much sense to tell the application layer
that it's cleanly closed and pass the received close code as-is though
there's a garbage fragment left in the WS protocol layer.

If we don't handle this as an error, it works as cancellation of the
incomplete fragments. Someone may consider this to be useful but I'm ok
without this.

So, we could do as follows
- Code 1000: send 1002, close TCP and then deliver (code=1006,
wasClean=false).
- Undefined codes in 1000-1999: converge into 1006 as I said in
http://www.ietf.org/mail-archive/web/hybi/current/msg10173.html and once
defined follow the policy we adopted for existing ones.
- 3000-4999: we don't know if each of them means an error or not, but since
they're outside of WebSocket protocol, I think we should handle them in the
same manner as 1000.

Takeshi