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

后端 未结 16 1465
攒了一身酷
攒了一身酷 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:29

    if you are using httpd/apache, you can add a file something like ws.conf and add this code to it. Also, this solution can proxy something like this "http://localhost:6001/socket.io" to just this "http://localhost/socket.io"

    
        RewriteEngine on
    
        #redirect WebSocket
        RewriteCond %{REQUEST_URI}  ^/socket.io            [NC]
        RewriteCond %{QUERY_STRING} transport=websocket    [NC]
        RewriteRule /(.*)           ws://localhost:6001/$1 [P,L]
    
        ProxyPass        /socket.io http://localhost:6001/socket.io
        ProxyPassReverse /socket.io http://localhost:6001/socket.io
    
    

提交回复
热议问题