title: websocket always triggers onerror(undefined) with Chrome, but not with Firefox
body: <p>With a websocket server(C program) running in Cygwin, which does the handshaking&amp;echoing back the messages from client.</p>
  
  <p>With Firefox(Version 13.0.1), the two parties work together very well - handshaking , receiving and echoing back.</p>
  
  <p>But with Chrome(Version 23.0.1271.97 m), after the handshaking step, the client always triggers onerror - "undefined", then onclose.</p>
  
  <p>I was wondering: 
  Are there any differences between Firefox and Chrome how they handle websocket?</p>
  
  <p>Here is the HTML code(Thanks to stackoverflow guys contribution):</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
      &lt;script type="text/javascript"&gt;
          function connect() {
              var ws = new WebSocket("ws://localhost:8080/service");
              ws.onopen = function () {
                  alert("About to send data");
                  ws.send("Hello World"); // I WANT TO SEND THIS MESSAGE TO THE SERVER!!!!!!!!
                  alert("Message sent!");
              };
  
              ws.onmessage = function (evt) {
                  alert("About to receive data");
                  var received_msg = evt.data;
                  alert("Message received = "+received_msg);
              };
              ws.onclose = function () {
                  // websocket is closed.
                  alert("Connection is closed...");
              };
              ws.onerror = function (evt) {
                  alert("ERROR: "+evt.data);
              };
          };
  
  
      &lt;/script&gt;
  &lt;/head&gt;
  &lt;body style="font-size:xx-large" &gt;
      &lt;div&gt;
      &lt;a href="#" onclick="connect()"&gt;Click here to start&lt;/a&gt;&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Here is data log captured on server side with Firefox:</p>
  
  <pre><code>websocket server received:
  0001  47 45 54 20 2f 73 65 72 76 69 63 65 20 48 54 54 GET /service HTT
  0002  50 2f 31 2e 31 0d 0a 48 6f 73 74 3a 20 6c 6f 63 P/1.1..Host: loc
  0003  61 6c 68 6f 73 74 3a 38 30 38 30 0d 0a 55 73 65 alhost:8080..Use
  0004  72 2d 41 67 65 6e 74 3a 20 4d 6f 7a 69 6c 6c 61 r-Agent: Mozilla
  0005  2f 35 2e 30 20 28 57 69 6e 64 6f 77 73 20 4e 54 /5.0 (Windows NT
  0006  20 36 2e 31 3b 20 57 4f 57 36 34 3b 20 72 76 3a  6.1; WOW64; rv:
  0007  31 33 2e 30 29 20 47 65 63 6b 6f 2f 32 30 31 30 13.0) Gecko/2010
  0008  30 31 30 31 20 46 69 72 65 66 6f 78 2f 31 33 2e 0101 Firefox/13.
  0009  30 2e 31 0d 0a 41 63 63 65 70 74 3a 20 74 65 78 0.1..Accept: tex
  0010  74 2f 68 74 6d 6c 2c 61 70 70 6c 69 63 61 74 69 t/html,applicati
  0011  6f 6e 2f 78 68 74 6d 6c 2b 78 6d 6c 2c 61 70 70 on/xhtml+xml,app
  0012  6c 69 63 61 74 69 6f 6e 2f 78 6d 6c 3b 71 3d 30 lication/xml;q=0
  0013  2e 39 2c 2a 2f 2a 3b 71 3d 30 2e 38 0d 0a 41 63 .9,*/*;q=0.8..Ac
  0014  63 65 70 74 2d 4c 61 6e 67 75 61 67 65 3a 20 65 cept-Language: e
  0015  6e 2d 75 73 2c 65 6e 3b 71 3d 30 2e 35 0d 0a 41 n-us,en;q=0.5..A
  0016  63 63 65 70 74 2d 45 6e 63 6f 64 69 6e 67 3a 20 ccept-Encoding:
  0017  67 7a 69 70 2c 20 64 65 66 6c 61 74 65 0d 0a 43 gzip, deflate..C
  0018  6f 6e 6e 65 63 74 69 6f 6e 3a 20 6b 65 65 70 2d onnection: keep-
  0019  61 6c 69 76 65 2c 20 55 70 67 72 61 64 65 0d 0a alive, Upgrade..
  0020  53 65 63 2d 57 65 62 53 6f 63 6b 65 74 2d 56 65 Sec-WebSocket-Ve
  0021  72 73 69 6f 6e 3a 20 31 33 0d 0a 4f 72 69 67 69 rsion: 13..Origi
  0022  6e 3a 20 6e 75 6c 6c 0d 0a 53 65 63 2d 57 65 62 n: null..Sec-Web
  0023  53 6f 63 6b 65 74 2d 4b 65 79 3a 20 61 41 48 6e Socket-Key: aAHn
  0024  63 31 77 66 6e 68 39 39 53 6d 59 67 4d 50 6b 4d c1wfnh99SmYgMPkM
  0025  57 77 3d 3d 0d 0a 50 72 61 67 6d 61 3a 20 6e 6f Ww==..Pragma: no
  0026  2d 63 61 63 68 65 0d 0a 43 61 63 68 65 2d 43 6f -cache..Cache-Co
  0027  6e 74 72 6f 6c 3a 20 6e 6f 2d 63 61 63 68 65 0d ntrol: no-cache.
  0028  0a 55 70 67 72 61 64 65 3a 20 77 65 62 73 6f 63 .Upgrade: websoc
  0029  6b 65 74 0d 0a 0d 0a                            ket....
  
  websocket server sent:
  0001  48 54 54 50 2f 31 2e 31 20 31 30 31 20 53 77 69 HTTP/1.1 101 Swi
  0002  74 63 68 69 6e 67 20 50 72 6f 74 6f 63 6f 6c 73 tching Protocols
  0003  0d 0a 55 70 67 72 61 64 65 3a 20 77 65 62 73 6f ..Upgrade: webso
  0004  63 6b 65 74 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e cket..Connection
  0005  3a 20 55 70 67 72 61 64 65 0d 0a 53 65 63 2d 57 : Upgrade..Sec-W
  0006  65 62 53 6f 63 6b 65 74 2d 41 63 63 65 70 74 3a ebSocket-Accept:
  0007  20 74 66 48 33 51 6f 70 47 2f 61 50 78 49 4c 65  tfH3QopG/aPxILe
  0008  55 75 49 39 48 38 34 46 49 35 63 77 3d 0d 0a 53 UuI9H84FI5cw=..S
  0009  65 63 2d 57 65 62 53 6f 63 6b 65 74 2d 50 72 6f ec-WebSocket-Pro
  0010  74 6f 63 6f 6c 3a 20 63 68 61 74 0d 0a 0d 0a    tocol: chat....
  
  Sent OKAY.
  
  websocket server received:
  0001  81 8b 75 cb 87 1a 3d ae eb 76 1a eb d0 75 07 a7 ..u...=..v...u..
  0002  e3                                              .
  
  websocket server sent:
  ...
  </code></pre>
  
  <p>Data log with Chrome:</p>
  
  <pre><code>websocket server received:
  0001  47 45 54 20 2f 73 65 72 76 69 63 65 20 48 54 54 GET /service HTT
  0002  50 2f 31 2e 31 0d 0a 55 70 67 72 61 64 65 3a 20 P/1.1..Upgrade:
  0003  77 65 62 73 6f 63 6b 65 74 0d 0a 43 6f 6e 6e 65 websocket..Conne
  0004  63 74 69 6f 6e 3a 20 55 70 67 72 61 64 65 0d 0a ction: Upgrade..
  0005  48 6f 73 74 3a 20 6c 6f 63 61 6c 68 6f 73 74 3a Host: localhost:
  0006  38 30 38 30 0d 0a 4f 72 69 67 69 6e 3a 20 6e 75 8080..Origin: nu
  0007  6c 6c 0d 0a 53 65 63 2d 57 65 62 53 6f 63 6b 65 ll..Sec-WebSocke
  0008  74 2d 4b 65 79 3a 20 6a 79 38 30 61 2b 50 72 73 t-Key: jy80a+Prs
  0009  35 48 71 62 36 62 58 50 2f 43 58 51 51 3d 3d 0d 5Hqb6bXP/CXQQ==.
  0010  0a 53 65 63 2d 57 65 62 53 6f 63 6b 65 74 2d 56 .Sec-WebSocket-V
  0011  65 72 73 69 6f 6e 3a 20 31 33 0d 0a 53 65 63 2d ersion: 13..Sec-
  0012  57 65 62 53 6f 63 6b 65 74 2d 45 78 74 65 6e 73 WebSocket-Extens
  0013  69 6f 6e 73 3a 20 78 2d 77 65 62 6b 69 74 2d 64 ions: x-webkit-d
  0014  65 66 6c 61 74 65 2d 66 72 61 6d 65 0d 0a 0d 0a eflate-frame....
  
  websocket server sent:
  0001  48 54 54 50 2f 31 2e 31 20 31 30 31 20 53 77 69 HTTP/1.1 101 Swi
  0002  74 63 68 69 6e 67 20 50 72 6f 74 6f 63 6f 6c 73 tching Protocols
  0003  0d 0a 55 70 67 72 61 64 65 3a 20 77 65 62 73 6f ..Upgrade: webso
  0004  63 6b 65 74 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e cket..Connection
  0005  3a 20 55 70 67 72 61 64 65 0d 0a 53 65 63 2d 57 : Upgrade..Sec-W
  0006  65 62 53 6f 63 6b 65 74 2d 41 63 63 65 70 74 3a ebSocket-Accept:
  0007  20 4d 39 2f 58 41 4e 67 35 52 32 58 4f 4d 50 49  M9/XANg5R2XOMPI
  0008  4d 67 2f 54 6b 50 38 6e 5a 38 67 6f 3d 0d 0a 53 Mg/TkP8nZ8go=..S
  0009  65 63 2d 57 65 62 53 6f 63 6b 65 74 2d 50 72 6f ec-WebSocket-Pro
  0010  74 6f 63 6f 6c 3a 20 63 68 61 74 0d 0a 0d 0a    tocol: chat....
  
  Sent OKAY.
  </code></pre>