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

后端 未结 16 1469
攒了一身酷
攒了一身酷 2020-12-04 21:08

I am trying to integrate Socket.io with Angular and I\'m having difficulties making a connection from the client-side to the server. I\'ve looked through other related quest

16条回答
  •  一个人的身影
    2020-12-04 21:48

    This worked for me with Nginx, Node server and Angular 4

    Edit your nginx web server config file as:

    server {
    listen 80;
    server_name 52.xx.xxx.xx;
    
    location / {
        proxy_set_header   X-Forwarded-For $remote_addr;
        proxy_set_header   Host $http_host;
        proxy_pass         "http://127.0.0.1:4200";
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection "upgrade";
    }
    

提交回复
热议问题