What could be the possible cause of the error Error during WebSocket handshake: Unexpected response code: 400?
The app is hosted on ubuntu and deployed using the npm mup package. I included my bundled ssl pem file within mup.json.
Is there anything else that I need to configure on the server?
This can be caused by one of the three reasons:
Some ISPs may use proxies which don't support websockets. This is more apparent over 3G networks
If your app has crashed. Meteor tries to connect to the server and can't since it's not online.
This can also happen if Nginx isn't configured to use WebSockets, and your MUP instance is sitting behind a WebSocket.
So if your app is working as expected (maybe just takes a bit too long to get connected) & has this error in development console it's likely due to a proxy server. To avoid this try getting SSL (https://) installed on your server too. This way the ISP or proxy is not able to alter your app's connection.
I had this error when I was connecting via a hotel WiFi. The problem was that you are always connecting to the internet via their proxy.
My solution to this was to use my mobile phone as a Wifi hotspot. I have Android 6.0.1, and you can access the menu through:
Settings > More > Tethering & portable hotspot > Set up Wi-Fi hotspot (and then enable 'Portable Wi-Fi hotspot')
Related
I have a nodejs web app with websocket , when i run on localhost it's not problem but when i run on public host (have SSL,domain name...) i get error : WebSocket connection to 'ws://127.0.0.1/ws' failed .
Question here is, where are you trying to connect from
Client OR Server
The error message would indicate you are trying to connect to a localhost, so if you are getting this message back from the client side, then its because your connecting to a non-reachable WS instance. Also, if you WS host is https, you would use WSS protocol vs just WS
As mentioned, without seeing the code its hard to tell
You need to setup your server environment, is your web-server (Apache, nginx) correctly pass requests from world to your node app?..
Is your server firewall pass WS connections?..
IMHO you need a consultation from your provider DevOp's support team.
You are using the following according to your statement:
ws://127.0.0.1/ws
From what I have read in the various ws api's while researching my own websocket issues I believe you would need to make the following change:
wss://127.0.0.1/ws
as wss is used for SSL connections.
I'm trying to develop a web application in nodejs. I'm using an npm package called "simple-peer" but i don't think this issue is related to that. I was able to use this package and get it working when integrating it with a laravel application using an apache server as the back end. I could access the host machine through it's IP:PORT on the network and connect a separate client to the host successfully with a peer-to-peer connection. However, I'm now trying to develop this specifically in node without an apache back end. I have my express server up and running on port 3000, I can access the index page from a remote client on the same network through IP:3000. But when I try to connect through webrtc, I get a "Connection failed" error. If I connect two different browser instances on the same localhost device, the connection succeeds.
For reference: i'm just using the copy/pasted code from this usage demo. I have the "simplepeer.min.js" included and referenced in the correct directory.
So my main questions are: is there a setting or some webRTC protocol that could be blocking the remote clients from connecting? What would I need to change to meet this requirement? Why would it work in a laravel/webpack app with apache and not with express?
If your remote clients can not get icecandidates, you need TURN server.
When WebRTC Peer behind NAT, firewall or using Cellular Network(like smartphone), P2P Connection will fail.
At that time, for fallback, TURN server will work as a relay server.
I recommend coTURN.
Here is an simple implementation of simple-peer with nodejs backend for multi-user video/audio chat. You can find the client code in /public/js/main.js. Github Project and the Demo.
And just like #JinhoJang said. You do need a turn server to pass the information. Here is a list of public stun/turn servers.
I've just created a new sails.js app with
sails new testProject
Then I did
sails lift
Now I navigate to my address (http://153.92.xx.xxx:1337) and everything works.
However, I know that sails uses XHR by default but tries to upgrade to WebSockets if it can. No matter what I try I can't get WebSockets to work.
I can see that the app tries to connect but is just (pending) for about 18 seconds before it gives up. It then goes back to XHR.
The error reads:
WebSocket connection to 'ws://153.92.xx.xxx:1337/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket&sid=8qjNepcGV5Rh3VvzAAAA' failed: Error during WebSocket handshake: net::ERR_CONNECTION_RESET
What could I be doing wrong?
Sailsjs v0.11.2
Nodejs v0.12.7
Debian 8 x64
iptables has full ACCEPT on everything
I believe this is because of a personal firewall.
Changing the port from 1337 to 80 made everything work.
Accessing the site from a different machine worked ok.
My best guess is that a personal firewall that was on my machine blocks websockets if they are not using "standard" ports.
I have a website behind cloudflare. I need to enable websockets over SSL without turning off cloudflare support. I have a PRO plan and hence won't get the new websocket support. I am using Nginx to proxy a SSL connection to a web socket running on a node server. Now, I read somewhere that cloudflare could work with approved ports would support websockets. Hence, I'm using 8443 for the Nginx port and another port for the node server. Using wscat it returns a 200 error.
$ wscat -c wss://xyz.com:8443
error: Error: unexpected server response (200)
I know that the websocket is expecting a 101 code. However, if I visit https://xyz.com:8443, I can see the page displayed by the node server telling me proxy is working. Also, once I turn off cloudflare support, the websocket starts working. Any clues to get this working. I know I can create a subdomain but I'd prefer running the websocket behind cloudflare.
If you're trying to access this through CloudFlare's network you'd need to explicitly have web sockets enabled on your domain before they will work -- regardless of the port. As in, even if the port can pass through our network, that won't automatically mean that web sockets will be enabled or accessible on your domain.
You can try contacting our support team to request an exception to see if they can enable it for your domain, but typically this is still only available at the business and enterprise levels.
Disclaimer: I work at CloudFlare.
My problem is simple to explain but not so simple to fix I think since I haven't found a solution yet.
I'm developing an API. The backend is developed using NodeJs and Socket.Io. Everything works perfect but the issue arises when I'm on a net that's behind a firewall, Squid in this case. It is the browser who is behind the firewall not the server (NodeJs).
The thing is that I get this error:
WebSocket connection to 'ws://mydomain.com/socket.io/1/websocket/vN8hWt_EjV0Z5P5-GwrW' failed: Unexpected response code: 502 (socket.io.js:2)
and I don't know how to the browser can skip Squid.