Bug 31659

Summary: Connection must be closed in case of Web Socket handshake error
Product: WebKit Reporter: Yuzo Fujishima <yuzo>
Component: WebKit Misc.Assignee: Alexey Proskuryakov <ap>
Status: RESOLVED FIXED    
Severity: Normal CC: ap, eric, ukai, yuzo
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
Attachments:
Description Flags
proposed fix oliver: review+

Description Yuzo Fujishima 2009-11-18 20:53:36 PST
Currently, WebKit times out in case of Web Socket handshake error (as caught by LayoutTests/websocket/tests/handshake-error.html)

It must close the connection instead.

http://www.w3.org/TR/2009/WD-websockets-20091029/
4 The WebSocket interface
...
If the "establish a Web Socket connection" algorithm fails, it triggers the "fail the Web Socket connection" algorithm, which then invokes the "close the Web Socket connection" algorithm, which then establishes that the "Web Socket connection is closed", which fires the close event as described below.
Comment 1 Yuzo Fujishima 2009-11-18 21:29:09 PST
Note: this bug was found while examining:
https://bugs.webkit.org/show_bug.cgi?id=31465

Yuzo
Comment 2 Alexey Proskuryakov 2009-11-26 13:03:34 PST
I don't understand what exactly fails here. According to <http://build.webkit.org/waterfall>, all tests currently pass. Does this particular test have identical output in success and failure cases? Or does it only fail with a patch from bug 31465 applied?
Comment 3 Yuzo Fujishima 2009-11-26 16:43:55 PST
Without 31465, the server calls a non-existent method, raises exception, and closes the socket.

With 31645, the server writes an invalid handshake response to the socket.

It seems that the client side can handle the socket closure case properly but not
the invalid response case -- the client times out for the latter.

Yuzo
Comment 4 Yuzo Fujishima 2009-11-26 16:45:44 PST
Sorry, s/31645/31465/g in #3.
Comment 5 Alexey Proskuryakov 2009-11-30 15:44:49 PST
Created attachment 44045 [details]
proposed fix
Comment 6 Oliver Hunt 2009-11-30 15:45:58 PST
Comment on attachment 44045 [details]
proposed fix

r=me
Comment 7 Alexey Proskuryakov 2009-11-30 15:49:43 PST
Committed <http://trac.webkit.org/changeset/51516>.