Reputation: 5302
I am banging my head for a couple of hours already because when i deploy my websockets in production server, it wont work. I keep on having this error: Error in connection establishment: net::ERR_CONNECTION_TIMED_OUT
.
These are my configuration:
In websockets.php
return [
/*
* 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,
],
],
....
In 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
]
],
],
In 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
});
I am not sure what i'm doing wrong here but it looks like i've followed all tutorials in the internet but with no avail, i am getting that error.
Thanks.
Upvotes: 0
Views: 2751
Reputation: 5302
Apologies, but I was able to solved this by opening the port that I chose to use in the server which in my case it is port 6002
. This is a very rookie mistake on my part, as I am not really that great in server stuff.
This is how you open a port How to open some ports on Ubuntu?
Anyway, thank you!
Upvotes: 1