javascript - Laravel-echo-server 无法使用 https 协议(protocol)启动生产

标签 javascript node.js laravel socket.io laravel-echo

我在 digitalocean 中托管了我的项目。我正在使用 laravel echo 服务器,它在 http 上运行良好,但是当我设置 letsencrypt 时,laravel echo 服务器无法启动。

这里是 laravel echo 服务器配置。

{   
    "authHost": "https://example.com/api/",
    "authEndpoint": "/broadcasting/auth",
    "clients": [
            {
                "appId": "86f96c2b2ca85e8a",
                "key": "0e917607d0910b9e2670d281a0e2b254"
            }
    ],
    "database": "redis",
    "databaseConfig": 
    {
        "redis": {},
        "sqlite": 
        {
            "databasePath": "/database/laravel-echo-server.sqlite"
        }
    },
    "devMode": true,
    "host": null,
    "port": "6001",
    "protocol": "https",
    "socketio": {},
    "sslCertPath": "/etc/letsencrypt/csr/0000_csr-certbot.pem",
    "sslKeyPath": "/etc/letsencrypt/keys/0000_key-certbot.pem",
    "sslCertChainPath": "",
    "sslPassphrase": "",
    "subscribers": 
    {
        "http": true,
        "redis": true
    },
    "apiOriginAllow": 
    {
        "allowCors": true,
        "allowOrigin": "http://localhost:80",
        "allowMethods": "GET, POST",
        "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
    }
}

我希望 laravel echo 服务器启动并监听事件,但无法启动并显示此错误。

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

version 1.5.0

⚠ Starting server in DEV mode...

(node:22827) UnhandledPromiseRejectionWarning: Error: error:0909006C:PEM routines:get_name:no start line
    at Object.createSecureContext (_tls_common.js:136:17)
    at Server (_tls_wrap.js:870:27)
    at new Server (https.js:62:14)
    at Object.createServer (https.js:85:10)
    at Server.httpServer (/usr/local/lib/node_modules/laravel-echo-server/dist/server.js:60:36)
    at /usr/local/lib/node_modules/laravel-echo-server/dist/server.js:34:35
    at process._tickCallback (internal/process/next_tick.js:68:7)
(node:22827) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:22827) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

最佳答案

我在尝试在生产环境中运行 Laravel Echo Server 时遇到了完全相同的问题。

尝试对 laravel-echo-server.json 文件进行以下更改:

"sslCertPath": "/etc/nginx/ssl/YOURPROJECT/601901/server.crt",
"sslKeyPath": "/etc/nginx/ssl/YOURPROJECT/601901/server.key",

用您的域更新 YOURPROJECT。如果您使用的是 Laravel Forge,这应该可以解决问题。

关于javascript - Laravel-echo-server 无法使用 https 协议(protocol)启动生产,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55824072/

相关文章:

javascript - 如何更新Backbone JS模型属性?

node.js - 使用 Expo start 而不是 npm start

php - Elasticsearch 7.7 损坏的查询

php - 如何配置 SCP/SFTP 文件存储?

javascript - 调整 Angular Material 中的圆形进度

javascript - Backbone : Event handler not defined?

javascript - 在 Angular JS 模块中传递并获取 DOM 元素值

linux - 密码在用户添加到 FreeIPA 后就过期了?

javascript - 在 javascript 中读取 iFrame 中 div 的状态(不在同一域 - YouTube)

javascript - 无法使用带有 ui-router AngularJS View 的不同 Controller