Getting WebSockets to Work on Windows Azure

Published on Sunday, February 9, 2014

I was banging my head against the wall for the past hour or so wondering why I was falling back to XHR polling when I deployed my Node.js application to Azure. I'm using socket.io and everything looks like it's in order, works locally, etc. It was failing with a WebSocket handshake error.

What I saw in the Chrome developer console was something like:

Error during WebSocket handshake: Unexpected response code: 502

In my Azure Node.js console (azure site log tail SITENAME), I was seeing EPIPE errors.

It turns out, this little tidbit from the original Windows Azure blog post on Web Sockets did the trick.

Modify your web.config and add:

<webSocket enabled="false" />

To your system.webServer configuration. Also, another good point in that blog post is to use SSL, since you get SSL for free with a *.azurewebsites.net site.

Hope this helps someone else out there. This should be added to the official Azure tutorial on using web sockets with Node.js.

About Kamran
I'm a technologist, speaker, and Pluralsight author and I specialize in building full-stack solutions with a focus on modern web technology and cloud native architecture.
comments powered by Disqus
comments powered by Disqus