kakajansh / echo

Laravel Echo for your Flutter apps.
MIT License
107 stars 68 forks source link

I can't connect to public channel #25

Closed GENL closed 4 years ago

GENL commented 4 years ago

Hi, what am I doing wrong. It does not not connect at all, not event on public channel.


class Broadcaster {
  static final host = '${Config.baseUrl.replaceFirst('/api/', '')}:6001';
  // static final host = 'http://c3fc4a713177.ngrok.io:6001';

  /// Global app singleton broadcaster instance.
  static final Echo instance = new Echo({
    'broadcaster': 'socket.io',
    // "authEndpoint": "/api/broadcasting/auth",
    'client': IO.io,
//    'auth': {
//      'headers': {
//        'Authorization': User.fromPrefs()?.token?.authorizationHeader ?? ''
//      }
//    },
    'host': host,
  });

  /// Initial broadcasting config.
  static void init() {
    print('In 0: ===>');
    // print('instance.sockedId() ${instance.sockedId()}');
    instance.socket.on('connect', (_) => print('socket connect ===> '));
    instance.socket.on('disconnect', (_) => print('socket disconnect ===> '));
    _listenPublicChannels();
  }

  static void _listenPublicChannels() {
    instance.channel('chan-post-visibility').listen('LightLikedEvent', (event) {
      print('LightLikedEvent Listened ===> ');
    });
    print('In 0:: ===>');
  }
}
GENL commented 4 years ago

It's ok. As I'm using ngrok to share my localhost, I had to generate a link to share the port 8000 and another to share the port 6001 for laravel echo server.