<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>13180</bug_id>
          
          <creation_ts>2011-07-07 21:41:12 +0000</creation_ts>
          <short_desc>[Editorial] Causes that lead to failing the WebSocket connection, which results in an error event, should be more clearly specified</short_desc>
          <delta_ts>2011-08-06 00:47:49 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebAppsWG</product>
          <component>WebSocket API (editor: Ian Hickson)</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WONTFIX</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Adrian Bateman [MSFT]">adrianba</reporter>
          <assigned_to name="Ian &apos;Hixie&apos; Hickson">ian</assigned_to>
          <cc>art.barstow</cc>
    
    <cc>brian.raymor</cc>
    
    <cc>ian</cc>
    
    <cc>mike</cc>
    
    <cc>public-webapps</cc>
          
          <qa_contact>public-webapps-bugzilla</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>50798</commentid>
    <comment_count>0</comment_count>
    <who name="Adrian Bateman [MSFT]">adrianba</who>
    <bug_when>2011-07-07 21:41:12 +0000</bug_when>
    <thetext>The reasons for failing the WebSocket connection are spread throughout the spec. It would be helpful to implementers to gather these together in a section that describes the error event.

There are a limited number of cases where this occurs based on my reading:
* There is a failure to establish a websocket connection
* The connection is closed before it is opened
* The WebSocket is disappeared before it is opened</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>51253</commentid>
    <comment_count>1</comment_count>
    <who name="Brian Raymor [MSFT]">brian.raymor</who>
    <bug_when>2011-07-19 04:55:30 +0000</bug_when>
    <thetext>
Are there additional &quot;Fail the WebSocket Connection&quot; cases from the protocol specification that should surface in an error event?

The current client-related list includes:
 
 
4.2.  Base Framing Protocol
 
  RSV1, RSV2, RSV3:  1 bit each
 
      MUST be 0 unless an extension is negotiated which defines meanings
      for non-zero values.  If a nonzero value is received and none of
      the negotiated extensions defines the meaning of such a nonzero
      value, the receiving endpoint MUST _Fail the WebSocket
      Connection_.
 
   Opcode:  4 bits
 
      Defines the interpretation of the payload data.  If an unknown
      opcode is received, the receiving endpoint MUST _Fail the
      WebSocket Connection_. 

5.1.  Client Requirements
 
  1.  The components of the WebSocket URI passed into this algorithm
       (/host/, /port/, /resource name/ and /secure/ flag) MUST be valid
       according to the specification of WebSocket URIs specified in
       Section 3.  If any of the components are invalid, the client MUST
       _Fail the WebSocket Connection_ and abort these steps.
 
   4.  If the connection could not be opened, either because a direct
       connection failed or because any proxy used returned an error,
       then the client MUST _Fail the WebSocket Connection_ and abort
       the connection attempt.
 
   5.  If /secure/ is true, the client MUST perform a TLS handshake over
       the connection after opening the connection and before sending
       the handshake data [RFC2818].  If this fails (e.g. the server&apos;s
       certificate could not be verified), then the client MUST _Fail
       the WebSocket Connection_ and abort the connection.
 
Server Responses:
 
   2.  If the response lacks an &quot;Upgrade&quot; header or the &quot;Upgrade&quot; header
       contains a value that is not an ASCII case-insensitive match for
       the value &quot;websocket&quot;, the client MUST _Fail the WebSocket
       Connection _.
 
   3.  If the response lacks a &quot;Connection&quot; header or the &quot;Connection&quot;
       header contains a value that is not an ASCII case-insensitive
       match for the value &quot;Upgrade&quot;, the client MUST _Fail the
       WebSocket Connection_.
 
   4.  If the response lacks a &quot;Sec-WebSocket-Accept&quot; header or the
       &quot;Sec-WebSocket-Accept&quot; contains a value other than the base64-
       encoded SHA-1 of the concatenation of the &quot;Sec-WebSocket-Key&quot; (as
       a string, not base64-decoded) with the string &quot;258EAFA5-E914-
       47DA-95CA-C5AB0DC85B11&quot;, but ignoring any leading and trailing
       whitespace, the client MUST _Fail the WebSocket Connection_
 
   5.  If the response includes a &quot;Sec-WebSocket-Extensions&quot; header, and
       this header indicates the use of an extension that was not
       present in the client&apos; handshake (the server has indicated an
       extension not requested by the client), the client MUST _Fail the
       WebSocket Connection_.  (The parsing of this header to determine
       which extensions are requested is discussed in Section 9.1.)
 
 
   If the server&apos;s response does not conform to the requirements for the
   server&apos;s handshake as defined in this section and in Section 5.2.2,
   the client MUST _Fail the WebSocket Connection_.
 

7.2.1.  Client-Initiated Closure
 
   Certain algorithms, namely during the opening handshake, require the
   client to _Fail the WebSocket Connection_.  To do so, the client MUST
   _Fail the WebSocket Connection_ as defined in Section 7.1.7.
 
   If at any point the underlying transport layer connection is
   unexpectedly lost, the client MUST _Fail the WebSocket Connection_.
 
   Except as indicated above or as specified by the application layer
   (e.g. a script using the WebSocket API), clients SHOULD NOT close the
   connection.
 
8.1.  Handling Errors in UTF-8 Encoded Data
 
   When an endpoint is to interpret a byte stream as UTF-8 but finds
   that the byte stream is not in fact a valid UTF-8 stream, that
   endpoint MUST _Fail the WebSocket Connection_.
 
9.1.  Negotiating Extensions
 
   A client requests extensions by including a &quot;Sec-WebSocket-
   Extensions&quot; header, which follows the normal rules for HTTP headers
   (see [RFC2616] section 4.2) and the value of the header is defined by
   the following ABNF.  Note that unlike other section of the document
   this section is using ABNF syntax/rules from [RFC2616].  If a value
   is received by either the client or the server during negotiation
   that does not conform to the ABNF below, the recipient of such
   malformed data MUST immediately _Fail the WebSocket Connection_.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54253</commentid>
    <comment_count>2</comment_count>
    <who name="Ian &apos;Hixie&apos; Hickson">ian</who>
    <bug_when>2011-08-05 15:44:33 +0000</bug_when>
    <thetext>Assuming you mean the references to &quot;fail the WebSocket connection&quot;, all those references are of things that happen on the protocol side, I believe. I don&apos;t really know how we could do anything in the API spec here. I recommend bringing this up with the hybi group.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>54279</commentid>
    <comment_count>3</comment_count>
    <who name="Brian Raymor [MSFT]">brian.raymor</who>
    <bug_when>2011-08-06 00:47:49 +0000</bug_when>
    <thetext>We&apos;re basically requesting minor editorial changes to help clarify the set of errors and how they&apos;re handled:

1. It would be helpful to organize the current set of &quot;fail the websocket connection&quot; (error) cases into one section for easier reference. Currently, the cases are scattered through the text.

2. Be more specific about whether these cases trigger onError since &quot;fail the websocket connection&quot; in the protocol draft indicates that onError behavior is a MAY:


   Certain algorithms and specifications require an endpoint to _Fail
   the WebSocket Connection_.  To do so, the client MUST _Close the
   WebSocket Connection_, and MAY report the problem to the user (which
   would be especially useful for developers) in an appropriate manner.

3. What is the behavior for the other &quot;fail the websocket connection cases related to the client in the protocol draft? For example, if a client receives an invalid UTF-8 byte stream and &quot;fails the websocket connection&quot; as required, does this also trigger onError?</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>