Fixed. I had forgotten that my Apache instance redirects incoming connections to www.{hostname} and I was not including www. in my host parameters for Laravel Echo Server and the Laravel Echo client. Hopefully, this helps somebody in the future.
TokenMismatchException thrown when Echo attempts to subscribe to private channel
My setup:
- Laravel 5.4 with Auth
- Laravel Echo Server running on port 2096 due to Cloudflare's WebSocket port restrictions
- Redis 3.2.8
Directory and Laravel config:
I have Laravel in my home directory with the proper file permissions set. There's a symlink at /var/www/html/dash which points to ~/laravel/public. In Laravel's .env file, APP_URL is set to my domain with /dash trailing (correct me if this should simply be the domain).
Laravel Echo Server config:
- authEndpoint is set to /dash/broadcasting/auth
- authHost is https://{hostname}
- host is blank
- port is 2096
- protocol is https
- socketio is an empty array
- sslCertPath and sslKeyPath are set properly
Echo Client config:
- broadcaster is socket.io
- host is https://{hostname}:2096
- authEndpoint is /dash/broadcasting/auth
The Issue:
Whenever I log into the Laravel application, the view loads properly and socketio is properly loaded from https://{hostname}:2096/socket.io/socket.io.js, but for some odd reason the authentication does not work properly. Laravel echo server outputs 6W23Ffb2M02MM4O7AAAA could not be authenticated to private-user.1 as well as Client can not be authenticated, got HTTP status 500
Any help is wildly appreciated!
Please or to participate in this conversation.