1

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?

LorenzoBerti
  • 6,704
  • 8
  • 47
  • 89
  • 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: https://stackoverflow.com/questions/56866032/configuring-apache-reverse-proxy-for-hosting-laravel-echo-server-on-production/56934080#56934080 – Maarten Veerman Oct 16 '20 at 21:35

2 Answers2

0

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

Bomzan
  • 36
  • 6
  • In allowOrigin I put "*", and the access static is not a problem, because, if that was the problem, i should receive a 403 and not a timeout – LorenzoBerti Oct 19 '20 at 07:13
  • I have same issue, please check screenshot https://i.stack.imgur.com/amODu.png – ALi Jan 16 '22 at 19:47
0

in laravel-echo-server.json you have a section named socketio that you can put your socketio settings here.

{
  "sid": "FSDjX-WRwSA4zTZMALqx",
  "upgrades": ["websocket"],
  "pingInterval": 25000,
  "pingTimeout": 20000
}

according to socketio documentation (Handshake and pingTimeout) there is an option named pingTimeout and default timeout is set to 20000 ms. you can increase timeout time according to the needs of the project.

H.Rad
  • 69
  • 6