<p dir="auto">I'm trying to connect to a local websocket server.</p>
<p dir="auto"><code class="notranslate">socket = new WebSocket("ws://localhost:30003");</code></p>
<p dir="auto">The socket never connects properly. When I try to do <code class="notranslate">socket.send()</code>, it throws a DOMException:</p>
<p dir="auto"><code class="notranslate">Uncaught DOMException: Failed to execute 'send' on 'WebSocket': Still in CONNECTING state.</code></p>
<p dir="auto">It works fine in Chrome 43. I've also tried running this code inside the Atom editor, it doesn't work.</p>
<p dir="auto">I'm connecting to a websocket server and would like to use the user agent string to record which app versions are hitting my server as specified here: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="23730729" data-permission-text="Title is private" data-url="https://github.com/electron/electron/issues/134" data-hovercard-type="issue" data-hovercard-url="/electron/electron/issues/134/hovercard" href="https://github.com/electron/electron/issues/134">#134</a></p>
<p dir="auto">Here is the headers my Golang websocket server is seeing as set</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="http.Header{&quot;Connection&quot;:[]string{&quot;Upgrade&quot;}, &quot;Pragma&quot;:[]string{&quot;no-cache&quot;}, &quot;Cache-Control&quot;:[]string{&quot;no-cache&quot;}, &quot;Upgrade&quot;:[]string{&quot;websocket&quot;}, &quot;Origin&quot;:[]string{&quot;file://&quot;}, &quot;Sec-Websocket-Version&quot;:[]string{&quot;13&quot;}, &quot;Accept-Encoding&quot;:[]string{&quot;gzip, deflate&quot;}, &quot;Sec-Websocket-Extensions&quot;:[]string{&quot;permessage-deflate; client_max_window_bits&quot;}, &quot;Accept-Language&quot;:[]string{&quot;en-us,en&quot;}, &quot;Sec-Websocket-Key&quot;:[]string{&quot;3PMSIjv8pr7CzxjnJI+LGw==&quot;}, &quot;User-Agent&quot;:[]string{&quot;”}}"><pre class="notranslate"><code class="notranslate">http.Header{"Connection":[]string{"Upgrade"}, "Pragma":[]string{"no-cache"}, "Cache-Control":[]string{"no-cache"}, "Upgrade":[]string{"websocket"}, "Origin":[]string{"file://"}, "Sec-Websocket-Version":[]string{"13"}, "Accept-Encoding":[]string{"gzip, deflate"}, "Sec-Websocket-Extensions":[]string{"permessage-deflate; client_max_window_bits"}, "Accept-Language":[]string{"en-us,en"}, "Sec-Websocket-Key":[]string{"3PMSIjv8pr7CzxjnJI+LGw=="}, "User-Agent":[]string{"”}}
</code></pre></div>
<p dir="auto">Possibly related to: <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="53733251" data-permission-text="Title is private" data-url="https://github.com/nwjs/nw.js/issues/2914" data-hovercard-type="issue" data-hovercard-url="/nwjs/nw.js/issues/2914/hovercard" href="https://github.com/nwjs/nw.js/issues/2914">nwjs/nw.js#2914</a></p>