failed: Error during WebSocket handshake: Unexpected response code: 400

1

I am using apache2 AWS server to deploy my project. My project is developed using NodeJS and ReactJS. For the last few days sever responds with this error,

WebSocket connection to 'wss://staging.socket.orgzee.com/socket.io/?EIO=3&transport=websocket&sid=raoen2FQ21DCbdxiAABN' failed: Error during WebSocket handshake: Unexpected response code: 400

Before getting this error, I have remove my node_modules and reinstall it from frontend(ReactJS side). That time I faced some errors as well. After getting the above error, I changes my server config file by adding the following code:

RewriteEngine on
RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
RewriteRule .* ws://18.221.58.135:3030%{REQUEST_URI} [P]

Then I got the CORS issue. I tried to fix the CORS error by setting :

Access-Control-Allow-Origin: '*'

Also I tried some cors libraries for NodeJS also but didn't help me at all. How do I fix this error??

sanil sathyan

Posted 2019-04-09T19:34:54.397

Reputation: 11

No answers