tlaverdure / laravel-echo-server

Socket.io server for Laravel Echo
MIT License
2.64k stars 509 forks source link

Unable to run laravel echo server on VPS production server CentOS? #538

Open 3ubeen3 opened 3 years ago

3ubeen3 commented 3 years ago

Describe the bug I have build a chat with socket io redis in laravel 5.8.everything works perfectly on localhost.But when i deploy it i am getting:

Failed to load resource: net::ERR_CONNECTION_REFUSED
https://my-domian.com:6001/socket.io/?EIO=3&transport=polling&t=NFHp_eW:1 

Laravel-echo-server.json:

{
    "authHost": "https://my-domian.com",
    "authEndpoint": "/broadcasting/auth",
    "clients": [],
    "database": "redis",
    "databaseConfig": {
        "redis": {},
        "sqlite": {
            "databasePath": "/database/laravel-echo-server.sqlite"
        }
    },
    "devMode": false,
    "host": "my-domian.com",
    "port": "6001",
    "protocol": "https",
    "socketio": {},
    "secureOptions": 67108864,
    "sslCertPath": "",
    "sslKeyPath": "",
    "sslCertChainPath": "",
    "sslPassphrase": "",
    "subscribers": {
        "http": true,
        "redis": true
    },
    "apiOriginAllow": {
        "allowCors": true,
        "allowOrigin": "https://my-domain.com",
        "allowMethods": "GET, POST",
        "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-Id"
    }
}

bootstrap.js:

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

if (typeof io !== 'undefined') {
    // alert('hiiiiiiiiiiiiiii--from-bootstap.js');
  window.Echo = new Echo({
    broadcaster: 'socket.io',
    host: window.location.hostname + ':6001',

    //auth

      headers: {
      'X-CSRF-TOKEN': $('meta[name=csrf-token]').attr('content'),
      }

  });
    console.log('Connected to socket.io');
} else {
    console.log('Not connected to socket.io');
}

I can see Connected to socket.io in console.But it seems problem with laravel echo server as it is not getting started.Please help me..Thanks...

Note:My-domain.com uses SSL..

Expected behavior My project is working well on localhost is it laravel echo server bug.help-me-please

nikhilo6july commented 3 years ago

try to use host as null

Any error when you start server ?

MisterDesenvolvimento commented 3 years ago

Did you fix it ?