【问题标题】:Laravel-echo-server , net::ERR_CONNECTION_TIMED_OUTLaravel-echo-server , net::ERR_CONNECTION_TIMED_OUT
【发布时间】:2019-07-05 10:34:56
【问题描述】:

我只在使用 laravel-echo-serverredisssl 的实时服务器上遇到了一个奇怪的问题。

错误: GET https://dev.my_domain.com:6001/socket.io/?EIO=3&transport=polling&t=Ml1g-Fq net::ERR_CONNECTION_TIMED_OUT

您可以在下面找到我的配置: laravel-echo-server.json

{
    "authHost": "https://dev.my_domain.com",
    "authEndpoint": "/broadcasting/auth",
    "clients": [],
    "database": "redis",
    "databaseConfig": {
        "redis": {
            "port": "6379",
                    "host": "127.0.0.1"
        }
    },
    "devMode": true,
    "host": null,
    "port": "6001",
    "protocol": "https",
    "socketio": {},
    "sslCertPath": "/etc/letsencrypt/live/dev.my_domain.com/fullchain.pem",
    "sslKeyPath": "/etc/letsencrypt/live/dev.my_domain.com/privkey.pem"
}

Bootstrap.js

import Echo from 'laravel-echo';

window.io = require('socket.io-client');

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

端口 6001 已启用: tcp6 0 0 :::6001 :::* LISTEN 10728/laravel-echo-

运行 laravel-echo-server 后启动

L A R A V E L  E C H O  S E R V E R

version 1.5.5

⚠ Starting server in DEV mode...

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

Server ready!

它在没有 ssl 配置的情况下在我的本地主机上正常工作。

如果有人对此问题有解决方案,请告诉我,

提前感谢大家

【问题讨论】:

  • 请关注here,可能对你有帮助。

标签: laravel websocket redis socket.io laravel-echo


【解决方案1】:

我找到了解决问题的方法。

下面的配置现在似乎没问题:),

首先你需要更新 apache2 配置: 启用模块:

a2enmod proxy_wstunnel

更新 apache 配置 位置:/etc/apache2/sites-available/**your_domain_config**.conf

在此处添加:

    SSLEngine on
    SSLProxyEngine On
    ProxyRequests Off
    ProxyPass        /socket.io http://dev.DOMAIN.com:6001/socket.io
    ProxyPassReverse /socket.io http://dev.DOMAIN.com:6001/socket.io

    RewriteEngine on
    RewriteCond %{HTTP:UPGRADE} ^WebSocket$ [NC]
    RewriteCond %{HTTP:CONNECTION} ^Upgrade$ [NC]
    RewriteRule .* ws://dev.DOMAIN.com:6001%{REQUEST_URI} [P]

重启 Apache:

systemctl restart apache2

我的 laravel-echo-server-json :

{
    "authHost": "https://dev.DOMAIN.com",
    "authEndpoint": "/broadcasting/auth",
    "clients": [],
    "database": "redis",
    "databaseConfig": {
        "redis": {
            "port": "6379",
            "host": "127.0.0.1"
        }
    },
    "devMode": true,
    "host": null,
    "port": "6001",
    "protocol": "https",
    "socketio": {},
    "sslCertPath": "/etc/letsencrypt/live/DOMAIN/fullchain.pem",
    "sslKeyPath": "/etc/letsencrypt/live/DOMAIN/privkey.pem"
}

更新 Bootstrap.js:

import Echo from 'laravel-echo';

window.io = require('socket.io-client');

window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: { path: '/socket.io' }
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-01-10
    • 2018-02-04
    • 1970-01-01
    • 2021-01-31
    • 1970-01-01
    • 2017-02-24
    • 2019-11-15
    • 2020-07-28
    相关资源
    最近更新 更多