0
votes

I know and I have seen this question

Getting ERR_CONNECTION_TIMED_OUT Laravel echo server

But I tried the solution in comment but it doesn't work.

I have my Laravel-echo-server.json

{
   "authHost": "https://mysite.it",
   "authEndpoint": "/broadcasting/auth",
   "clients": [],
   "database": "redis",
   "databaseConfig": {
   "redis": {
      "host":"0.0.0.0",
      "port":"6379",
      "password": "mypwd"
   },
   "sqlite": {
      "databasePath": "/database/laravel-echo-server.sqlite"
    }
  },
   "devMode": true,
   "host": null,
   "port": "6001",
   "protocol": "https",
   "socketio": {},
   "secureOptions": 67108864,
   "sslCertPath": "path_cert" ,
   "sslKeyPath": "path_key" ,
   "sslCertChainPath": "",
   "sslPassphrase": "",
   "subscribers": {
      "http": true,
      "redis": true
   },
   "apiOriginAllow": {
   "allowCors": true,
   "allowOrigin": "*",
   "allowMethods": "GET, PoST",
   "allowHeaders": "Origin, Content-Type, X-Auth-Token, X-Requested -With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-IdOrigin, Content-Type, X-A uth-Token, X-Requested-With, Accept, Authorization, X-CSRF-TOKEN, X-Socket-IdOri gin, Content-Type, X-Auth-Token, X-Requested-With, Accept, Authorization, X-CSRF -TOKEN, X-Socket-Id"
   }
}

And I have in my bootstrapjs the connection with Frontend:

import Vue from 'vue'
import Echo from 'laravel-echo'
window.io = require('socket.io-client')
export var echo_instance = new Echo({
   broadcaster: 'socket.io',
   host: window.location.hostname + ':6001',
   auth: {
      headers: {
        'Authorization': "Bearer " + localStorage.getItem('token')
      }
   }
})
Vue.prototype.$echo = echo_instance
export default Vue

I have check if the port was closed but with netstat -an I can see:

tcp6 0 0 :::6001 :::* LISTEN

But when I try to launch my app i receive:

app.js:569 GET https://mysite.it:6001/socket.io/?EIO=3&transport=polling&t=NKoWZoK net::ERR_CONNECTION_TIMED_OUT

How can I use the laravel echo with https protocol?

1
Better to setup your server in such a way that the echo communication is on port 443, and let your server decide if it's a standard or websockets request. In case of websockets, forward to echo server. For example: stackoverflow.com/questions/56866032/… - Maarten Veerman

1 Answers

0
votes

this might be because you have the wrong access token(dynamically added). why don't you try using a static access token first (copy the access token and paste it instead of localStorage.getItem('token')) for the user and see if it works.

Also try putting the following in laravel-echo-server.json file

"allowOrigin": "http://mysite.it:80"

And, see if APP_URL is different in .env file