Laravel 套接字.io客户端无法连接到Larvel echo服务器

Laravel 套接字.io客户端无法连接到Larvel echo服务器,laravel,socket.io,broadcasting,laravel-echo,Laravel,Socket.io,Broadcasting,Laravel Echo,我不知道为什么我的设置不起作用 我已经在vps服务器上设置了我的应用程序,我正在尝试让广播工作,但没有完全成功。由于超时,我无法使套接字客户端连接到服务器?它一直尝试重新连接,但没有成功 在客户端设置: import SocketClient from 'socket.io-client'; import Echo from "laravel-echo" import store from './store' import {renderResponseMessage} from 'Compon

我不知道为什么我的设置不起作用

我已经在vps服务器上设置了我的应用程序,我正在尝试让广播工作,但没有完全成功。由于超时,我无法使套接字客户端连接到服务器?它一直尝试重新连接,但没有成功

在客户端设置

import SocketClient from 'socket.io-client';
import Echo from "laravel-echo"
import store from './store'
import {renderResponseMessage} from 'Components/ChatWidget'
import {increaseNewMessagesCount} from 'Actions/chatActions'

window.io = SocketClient;
window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: window.location.hostname + ':6001'
});


window.Echo.channel('chat')
    .listen('NewChatMessage', ({message}) => {

        store.dispatch(increaseNewMessagesCount());
        renderResponseMessage(message)

    })

const getSocketId = () => window.Echo.socketId();

export {
    getSocketId
}
laravel echo server.json

{
        "authHost": "http://localhost",
        "authEndpoint": "/broadcasting/auth",
        "clients": [],
        "database": "redis",
        "databaseConfig": {
                "redis": {},
                "sqlite": {
                        "databasePath": "/database/laravel-echo-server.sqlite"
                }
        },
        "devMode": true,
        "host": null,
        "port": "6001",
        "protocol": "http",
        "socketio": {},
        "sslCertPath": "",
        "sslKeyPath": "",
        "sslCertChainPath": "",
        "sslPassphrase": "",
        "apiOriginAllow": {
                "allowCors": false,
                "allowOrigin": "",
                "allowMethods": "",
                "allowHeaders": ""
        }
laravel echo服务器监视器 客户端未连接到服务器

⚠ Starting server in DEV mode...

✔  Running at localhost on port 6001
✔  Channels are ready.
✔  Listening for http events...
✔  Listening for redis events...

Server ready!

Channel: chat
Event: App\Events\NewChatMessage
CHANNEL chat
nginx.conf

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        listen       [::]:80 default_server;
        server_name  _;
        root         /var/www/LegendaJaroslaw/public/;
        index           index.php;
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
           try_files $uri $uri/ /index.php?$query_string;
        }

         error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

# Settings for a TLS enabled server.
#
#    server {
#        listen       443 ssl http2 default_server;
#        listen       [::]:443 ssl http2 default_server;
#        server_name  _;
#        root         /usr/share/nginx/html;
#
#        ssl_certificate "/etc/pki/nginx/server.crt";
#        ssl_certificate_key "/etc/pki/nginx/private/server.key";
#        ssl_session_cache shared:SSL:1m;
#        ssl_session_timeout  10m;
#        ssl_ciphers HIGH:!aNULL:!MD5;
#        ssl_prefer_server_ciphers on;
#
#        # Load configuration files for the default server block.
#        include /etc/nginx/default.d/*.conf;
#
#        location / {
#        }
#
#        error_page 404 /404.html;
#            location = /40x.html {
#        }
#
#        error_page 500 502 503 504 /50x.html;
#            location = /50x.html {
#        }
#    }

}

我确实在流浪者的家园上使用了广播,但我无法找到生产服务器的解决方案。这与nginx配置有关吗?我不知道如何比较生产配置和homestead。

我在laravel-echo-server.json中尝试了多种主机变体。 这个值不起作用,
['127.0.0.1','localhost',null]
但是
“0.0.0.0”
起了作用


如果有人能解释它为什么起作用或指出一些来源,我会很高兴

你在哪里做的改变?不幸的是在我的情况下不起作用