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

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:// 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??

Reset to default

Know someone who can answer? Share a link to this question via email, Twitter, or Facebook.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like