0
votes

A lot of companies or work places have secutiry protocols in place where only the common ports are open, e.g. 80 (HTTP), 443 (HTTPS). If we were to have our web app try connecting to port 6001 (by default of laravel-echo-server), definitely some of your users will encounter problems as the port is closed... Source

After creating a subdomain in nginx, I launched sockets through it and it worked, except that now I can’t connect to any channel. Client can not be authenticated, got HTTP status 419"message": "CSRF token mismatch.",

Experimentally disabled csrf protection and the error changed to Client can not be authenticated, got HTTP status 403 "message": "",

app.js

/**
 * Port configured on proxy server (default: 6001).
 * The default port for HTTPS protocol is 443.
 *
 * @type {string}
 */
const ECHO_DOMAIN = process.env.NODE_ENV === 'production'
    ? 'ws.site.com'
    : 'wsdev.site.com';

window.io = require('socket.io-client');

if (typeof io !== 'undefined') {
    window.Echo = new Echo({
        broadcaster: 'socket.io',
        host: `https://${ECHO_DOMAIN}`,
        reconnectionAttempts: 120
    });
...

successful connection enter image description here

How to fix it?

1

1 Answers

0
votes

Issue resolved by adding a variable SESSION_DOMAIN=.site.com in .env, wich changes value in 'domain' in config/session.php

Then you need to clear cookies in browser, and the cache on server. You may also need to do composer dump-autoload. Primary source