Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Connecting to Socket.IO server hosted on Azure Mobile Services returns Error

I am attempting to connect to a Socket.IO server hosted in the extension folder of my Azure Mobile service using the startup script, although I am unable to do so, and receive the error:

"WebSocket connection to 'ws://mymobileservice.azure-mobile.net/extensions/socket.io/?EIO=2&transport=websocket' failed: Error during WebSocket handshake: Unexpected response code: 503"

I am using port 80 with a path of 'extensions/socket.io' I've also used port 443 with a secure connection, and that has yielded the same error.

Am I on the right track? Any help is greatly appreciated.

like image 928
msdedwards Avatar asked Oct 01 '14 19:10

msdedwards


People also ask

Why is Socket.IO not connecting?

Problem: the socket is not able to connect​You are trying to reach a plain WebSocket server. The server is not reachable. The client is not compatible with the version of the server. The server does not send the necessary CORS headers.

Does Socket.IO work on mobile?

The first step is to install the Java Socket.IO client with Gradle. We must remember adding the internet permission to AndroidManifest. xml . Now we can use Socket.IO on Android!


1 Answers

You figured this out, but here's a definitive answer.

The best way to host a socket.io server is to host it on Azure Websites directly (Azure > New > Website) instead of Azure Mobile Services. Once you publish your socket IO server to the website, don't forget to go to the "Configure" tab and enable "Websockets" for the server.

There is an amazing tutorial on deploying the socket.io chat app to azure websites here: https://azure.microsoft.com/en-us/documentation/articles/web-sites-nodejs-chat-app-socketio/

like image 170
David Washington Avatar answered Oct 18 '22 22:10

David Washington