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.
Problem: the socket is not able to connectYou 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.
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!
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/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With