0
votes

I use redis on laradock, and passport to authenticated channel. if i use public channel, socket is connected, but if i modify channel event in NewMessage.php to private, i get error Error sending authentication request when trying to authenticate . anyone have same problem? how to resolve it?

laravel-echo-server.json configuration:

{
    "authHost": "http://platform.lenna.test/app/public",
    "authEndpoint": "/broadcasting/auth",
    "clients": [],
    "database": "redis",
    "databaseConfig": {
        "redis": {
            "port": "6379",
            "host": "redis"
        }
    },
    "devMode": true,
    "host": null,
    "port": "6001",
    "protocol": "http",
    "socketio": {},
    "sslCertPath": "",
    "sslKeyPath": "",
    "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"
    }
}

this is my laravel event NewMessage.php

...
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class NewMessage implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    public $message;
    public $app;
    public $room;
    public function __construct(Message $message, Room $room, App $app)
    {
        $this->message = $message;
        $this->app = $app;
        $this->room = $room;
    }

    public function broadcastOn()
    {
        return new PrivateChannel('ChannelApp.' . $this->app->id);
    }
}

BroadcastServiceProvider.php

class BroadcastServiceProvider extends ServiceProvider
{
    public function boot()
    {
        Broadcast::routes(['middleware' => ['auth:api']]);

        require base_path('routes/channels.php');
    }
}

Channel.php routes

Broadcast::channel('ChannelApp.{appId}', function ($user, $appId) {
    return true;
})

This is my laravel-echo-server error logs:

enter image description here

1
Please post error logs and code as text and not as an image! This doesn't make sense. - thmspl
@thmspl i've improve my question - ival
As you can read (by your self!) in the error message you are trying to connec to the host 127.0.0.1 with port 80 and he's not answering your request. So this can have 1000 reasons and to debug this you need to post every related code you have. It should be clear that nobody can help you with such a common error message and so little code you've posted! First check that the metnioned host and port is correct. Then check every log file if there are more informations. - thmspl

1 Answers

0
votes

I had similar issue, What i discovered was the laravel-echo-server resolves the "http://platform.lenna.test" to 127.0.0.1.

So what I did was added the "nginx docker ip platform.lenna.test" to the /etc/hosts of laravel-echo-server and that worked for me.