Taras Chernata
Taras Chernata

Reputation: 401

Laravel Echo Server: "Error sending authentication request" on production using HTTPS (Private/Presence channel subscription_error)

I created realtime chat app using: Laravel 5.8, Laravel Echo, Redis, Socket.io and Vue.js.

It works fine on my local machine(localhost). But when I tried to move the app to production server(which has https) - it stopped working and it shows me the next error in laravel-echo-server.log file:

laravel-echo-server.log error

Also I've changed laravel-echo-server.json(echo server config file) like so:

laravel-echo-server.json content

Also you can see how window.Echo config looks like(in app.js):

import Echo from 'laravel-echo'
window.io = require('socket.io-client');

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

May be I have some bugs in the configs which mentioned above?

Also, I think it must be helpful, check the screenshot below what I have noticed in one of client's requests:

client's request error

I tried to find more information about the error and why it could appear but no results. Exactly I checked laravel log file - it was empty, and nginx error.log file which was empty too, the only place where I saw error it's laravel-echo-server.log file(I shoved its content above)

for additional information you can check what settings I'm using for redis server in my .env file (I cleared cache when changed .env):

...

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

...

Also, that's what I have in my config/database.php file:

...

'redis' => [

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

    'options' => [
        'cluster' => env('REDIS_CLUSTER', 'predis'),
    ],

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

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

],

...

Thank you guys so much for any help, I have been struggling with that problem for the last few days and I can't figure it out, so I will be gratefull for any tips!

Upvotes: 1

Views: 3767

Answers (2)

kishan maru
kishan maru

Reputation: 31

Run This Command In Terminal

sudo nano /etc/hosts

Add your project host in Host entry

127.0.0.1 https://naturalselection.ie

And Save The File

After Run This Command In Terminal

laravel-echo-server start

And enjoy your live Notification With Laravel Echo

Upvotes: 2

Taras Chernata
Taras Chernata

Reputation: 401

I sorted it out.

To fix that kind of issue you must go to /etc/hosts and paste there the next text: 127.0.0.1 your_domain_name.com

sudo nano /etc/hosts
127.0.0.1 your_domain_name.com

That's all, Hope it will help anybody :)

Upvotes: 1

Related Questions