Laravel-echo-server, Redis and Ubuntu 18.04.4 [ioredis] Error: connect ETIMEDOUT

Viewed 843

I hope someone can help me in solving this problem:

I have my laravel project (7.x) broadcasting without problems on local environment (Laragon 4.0 with redis). I wanted to move it live to make some more accurate test on my VPS with Ubuntu 18.04.4, apache2, virtualmin cp.

I did install redis server (latest version) and is up and running (PING -> PONG, create key->value, read key->value... restart service and key->value still there... all tests working great). When I fire my event and broadcast something I see it in queue:work regularly, but everytime I launch LARAVEL ECHO SERVER and the client connects very fast and after few seconds I start to receive this error in console:

[ioredis] Unhandled error event: Error: connect ETIMEDOUT
at Socket.<anonymous> (/usr/local/lib/node_modules/laravel-echo-server/node_modules/ioredis/built/redis/index.js:285:37)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:106:13)
at Socket.emit (events.js:208:7)
at Socket._onTimeout (net.js:420:8)
at ontimeout (timers.js:482:11)
at tryOnTimeout (timers.js:317:5)
at Timer.listOnTimeout (timers.js:277:5)

I checked every single post here on stackoverflow, laracasts and everywhere this error is mentioned but I cannot find a solution. The interested part of my .env file is here:

APP_NAME=Testapp
APP_ENV=local
APP_KEY=[omitted]
APP_DEBUG=true
APP_URL=[omitted]
LOG_CHANNEL=stack
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=17306
DB_DATABASE=[omitted]
DB_USERNAME=[omitted]
DB_PASSWORD=[omitted]
BROADCAST_DRIVER=redis
CACHE_DRIVER=none
QUEUE_CONNECTION=redis
SESSION_DRIVER=database
SESSION_LIFETIME=1200
REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

Here is Broadcasting.php

    'default' => env('BROADCAST_DRIVER', 'null'),

/*
|--------------------------------------------------------------------------
| Broadcast Connections
|--------------------------------------------------------------------------
|
| Here you may define all of the broadcast connections that will be used
| to broadcast events to other systems or over websockets. Samples of
| each available type of connection are provided inside this array.
|
*/

'connections' => [

    '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,
        ],
    ],

    'redis' => [
        'driver' => 'redis',
        'connection' => 'default',
    ],

My Database.php

    'redis' => [

    'client' => env('REDIS_CLIENT', 'phpredis'),

    'options' => [
        'cluster' => env('REDIS_CLUSTER', 'redis'),
        'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_database_'),
    ],

    'default' => [
        'url' => env('REDIS_URL'),
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', '6379'),
        'database' => env('REDIS_DB', '0'),
    ],

    'cache' => [
        'url' => env('REDIS_URL'),
        'host' => env('REDIS_HOST', '127.0.0.1'),
        'password' => env('REDIS_PASSWORD', null),
        'port' => env('REDIS_PORT', '6379'),
        'database' => env('REDIS_CACHE_DB', '1'),
        'timeout' => 10000,
    ],

My laravel-echo-server.json

{
"authHost": "127.0.0.1",
"authEndpoint": "/broadcasting/auth",
"clients": [],
"database": "redis",
"databaseConfig": {
    "redis": {},
    "sqlite": {
        "databasePath": "/database/laravel-echo-server.sqlite"
    }
},
"devMode": true,
"host": null,
"port": "6001",
"protocol": "https",
"socketio": {},
"secureOptions": 67108864,
"sslCertPath": "/home/[myuser]/ssl.cert",
"sslKeyPath": "/home/[myuser]/ssl.key",
"sslCertChainPath": "",
"sslPassphrase": "",
"subscribers": {
    "http": true,
    "redis": true
},
"apiOriginAllow": {
    "allowCors": false,
    "allowOrigin": "",
    "allowMethods": "",
    "allowHeaders": ""
}

}

The ports on firewall should be open and I find the services listening on their ports.

I really don't know what else to do, please if someone can help me because I'm getting old and I want to solve it before I retire :)

Thanks,

Simone

UPDATE

I did configure Redis on a unixsocket and avoid network problems, now working good.

0 Answers
Related