Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Echo with NodeJS HTTPS doesn't work #219

Closed
ghost opened this issue Jan 5, 2019 · 3 comments
Closed

Echo with NodeJS HTTPS doesn't work #219

ghost opened this issue Jan 5, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 5, 2019

Hi there, I've been developing this NodeJS application that takes advantage of Laravel Echo's functionalities to receive information from a server through socket connection.

Server-side

  • Laravel Echo Server with Laravel 5.7.19

Client-side
"laravel-echo": "^1.5.2"
"socket.io": "^2.2.0"

import Echo from '../../node_modules/laravel-echo/dist/echo.common.js'
import Socketio from 'socket.io-client';

let echo = new Echo({ 

      broadcaster: 'socket.io',
      host: 'https://smartfish.danymota.com:8080/',
      encrypted: true,
      secure: true,
      client: Socketio,
      auth: {
        headers: {
          'Authorization': 'Bearer ' + this.token.bearerToken,
        },
      },
    });
    echo.private('central.' + macAddress)
      .listen('RulesUpdated', (response) => {
        handleRules(JSON.parse(response.aquarios))
        console.log(new Date().toLocaleString() + " - Rules updated")
      })

Problem
Everything works fine in Http, when I switch to HTTPS it just stops working.
Also, if I run the application in a browser, everything works fine. Thats why I tried to play around with a bunch of factors such as the URL (/socket.io, wss, etc), the options passed on initialization, etc. All in vain.

Socket.io debug
socket.io-client:url parse https://smartfish.danymota.com:8080/socket.io +0ms
socket.io-client new io instance for https://smartfish.danymota.com:8080/socket.io +0ms
socket.io-client:manager readyState closed +0ms
socket.io-client:manager opening https://smartfish.danymota.com:8080/socket.io +0ms
socket.io-client:manager connect attempt will timeout after 20000 +4ms
socket.io-client:manager readyState opening +1ms
socket.io-client:manager connect_error +60ms
socket.io-client:manager cleanup +0ms

Thank you all in advance.

@ghost ghost changed the title Echo with NodeJS HTTPS does't work Echo with NodeJS HTTPS doesn't work Jan 7, 2019
@driesvints
Copy link
Member

Can you first please try one of the following support channels? If you can actually identify this as a bug, feel free to report back.

@ghost
Copy link
Author

ghost commented Jan 8, 2019

Thanks for the aswer.
Posting this here, so that people can follow up on the issue.
https://stackoverflow.com/questions/54091123/laravel-echo-with-nodejs-https-doesnt-work

@ghost
Copy link
Author

ghost commented Jan 10, 2019

I've solved the problem by adding rejectUnauthorized: false to echo

this.echo = new Echo({ broadcaster: 'socket.io', host: config.ECHO_SERVER, client: Socketio, rejectUnauthorized: false, auth: { headers: { 'Authorization': 'Bearer ' + this.token.bearerToken, }, }, })

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant