The front-end and back-end architecture are separated, the development environment is normal, and the errors reported when deploying to the line are as follows:
Websocket error: websocket failed: error during websocket Handshake: unexpected response code: 400
It is obvious that the configuration of nginx does not support the reverse proxy of websocket, so the search and troubleshooting results are as follows:
The most important of them are the three lines
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
The first line tells nginx to use HTTP/1.1 communication protocol, which websoket must use. The second and third lines tell nginx to respond to the HTTP upgrade request when it wants to use websocket. Here, HTTP and websocket reverse proxy coexist, just a protocol upgrade
Supplement:
server {
listen 80;
server_name school.godotdotdot.com;
charset utf-8;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
location/{
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 60;
proxy_read_timeout 600;
proxy_send_timeout 600;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
Read More:
- Deployment project websocket failed: error during websocket Handshake: unexpected response code: 400
- failed: Error during WebSocket handshake: Unexpected response code: 400
- failed: Error during WebSocket handshake: Unexpected response code: 200
- WebSocket handshake Unexpected response code 403
- Websocket code 200 error
- Jupyter failed to run websocket error
- Nginx manager jupyter notebook v1.0.0 http websocket
- When websocket transmits JSON text, the parse method reports an error
- Solution of error report in springboot Maven package websocket
- Response code: Sampler error: unexpected frame type (binary).
- JMeter running error response code: non HTTP response code: java.lang.illegalargumentexception find and solve
- JS Ajax request is successful, the response displays “failed to load response data”
- Solution: DevTools failed to load SourceMap:… net::ERR_HTTP_RESPONSE_CODE_FAILURE problem
- SQL Server SSPI handshake failed Error
- git clone https:// gnutls_handshake() failed: The TLS connection was non-properly terminated.
- gnutls_handshake() failed: A TLS fatal alert has been received
- Node.JS “Cannot enqueue Handshake after invoking quit” Error (Fixed)
- SSL handshake failed: SSL error: illegal key usage detected in the certificate
- ASP.NET How to deal with “unexpected character” when writing code
- MySQL Workbench Failed to Connect to MySQL at 127.0.0.1:3306 with user root Bad handshake