【发布时间】:2020-05-10 06:30:26
【问题描述】:
我已经敲了几个小时的头,因为当我在生产服务器中部署我的 websockets 时,它不会工作。我一直有这个错误:Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT。
这些是我的配置:
在websockets.php
返回 [
/*
* Set a custom dashboard configuration
*/
'dashboard' => [
'port' => env('LARAVEL_WEBSOCKETS_PORT', 6002),
],
/*
* This package comes with multi tenancy out of the box. Here you can
* configure the different apps that can use the webSockets server.
*
* Optionally you specify capacity so you can limit the maximum
* concurrent connections for a specific app.
*
* Optionally you can disable client events so clients cannot send
* messages to each other via the webSockets.
*/
'apps' => [
[
'id' => env('PUSHER_APP_ID'),
'name' => env('APP_NAME'),
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'path' => env('PUSHER_APP_PATH'),
'capacity' => null,
'enable_client_messages' => false,
'enable_statistics' => true,
],
'ssl' => [
/*
* Path to local certificate file on filesystem. It must be a PEM encoded file which
* contains your certificate and private key. It can optionally contain the
* certificate chain of issuers. The private key also may be contained
* in a separate file specified by local_pk.
*/
'local_cert' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_CERT', null),
/*
* Path to local private key file on filesystem in case of separate files for
* certificate (local_cert) and private key.
*/
'local_pk' => env('LARAVEL_WEBSOCKETS_SSL_LOCAL_PK', null),
/*
* Passphrase for your local_cert file.
*/
'passphrase' => env('LARAVEL_WEBSOCKETS_SSL_PASSPHRASE', null),
'verify_peer' => false,
],
],
....
在broadcasting.php
'pusher' => [
'driver' => 'pusher',
'key' => env('PUSHER_APP_KEY'),
'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'),
'options' => [
'cluster' => env('PUSHER_APP_CLUSTER'),
// 'useTLS' => true, //live
// 'encrypted' => true, //comment out in local
'host' => '127.0.0.1',
'port' => 6002,
'scheme' => 'https', //in live this is https
// 'scheme' => 'http' //in local this is only http,
'curl_options' => [
CURLOPT_SSL_VERIFYHOST => 0,
CURLOPT_SLL_VERIFYPEER => 0
]
],
],
在bootstrap.js
import Echo from 'laravel-echo';
window.Pusher = require('pusher-js');
window.Echo = new Echo({
broadcaster: 'pusher',
key: process.env.MIX_PUSHER_APP_KEY,
cluster: process.env.MIX_PUSHER_APP_CLUSTER,
forceTLS: true, //for live
// encrypted: false, //local
encrypted: true, //live
wsHost: window.location.hostname,
wsPort: 6002,
wssPort: 6002, //in local, comment this one
// enabledTransports: ['ws','wss'],
disableStats: true
});
我不确定我在这里做错了什么,但看起来我已经按照互联网上的所有教程进行操作,但无济于事,我收到了那个错误。
谢谢。
【问题讨论】:
标签: laravel websocket pusher laravel-echo