S
S
semki0962020-02-26 12:18:18
Nginx
semki096, 2020-02-26 12:18:18

Why is there no websocket connection?

Added config to Nginx

server {
        listen 8010;
        location / {
            proxy_pass http://mysite.ru;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection $connection_upgrade;
            proxy_set_header Host $host;
        }
    }


Here is the client
componentDidMount() {
      this.socket = new WebSocket('ws://mysite.ru:8010');
      
      this.socket.onopen = function() {
        alert("Соединение установлено.");
      };
      ...


I get an error
app.js:91683 WebSocket connection to 'ws://mysite.ru:8010/' failed: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT


I look in the developer tool - the request header "Provisional headers are shown" Maybe the server is not responding and it's the nginx settings? I will be grateful for help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
semki096, 2020-02-26
@semki096

I will leave here an example of setting https://github.com/beyondcode/laravel-websockets/i...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question