Mubeenali
1 month ago
250
2
Laravel

Laravel redis socket io connection refused error on Live VPS Server.

Posted 1 month ago by Mubeenali

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"
    }
}

resources/js/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..

Please sign in or create an account to participate in this conversation.