Search code examples
laravelflutterpusher

Flutter Laravel Echo


I'm new in Flutter Dev and I want to connect pusher using laravel app to my Flutter app.When subscribing to the event,Flutter binds the Event.I realised that the app is not being able to connect.I receive the http exception ,I don't know exactly which kind of exception.

PusherOptions options = PusherOptions(
  host: 'http://www.api.dassam.net',
  port: 80,
  encrypted: false,
  activityTimeout: 1200000
);

FlutterPusher pusher =
    FlutterPusher('XXXXXX', options, enableLogging: true,
        onConnectionStateChange: (ConnectionStateChange x) async {
     print(x.currentState);
},onError: (ConnectionError y)=>{
  print(y.exception)
});

Echo echo = new Echo({
  'broadcaster': 'pusher',
  'client': pusher,
  "useTLS": false,
});

echo.channel('public').listen('EssaiEvent', (e) {
  print('BIEN REUSSI
});

Solution

  • I found the solution.I change the host "http://dassam.net" to pusher wshost and it's working.

        PusherOptions options = PusherOptions(
        host: 'ws-ap2.pusher.com',
        port: 80,
        encrypted: false,
        cluster: "ap2",
        activityTimeout: 120000);
    
    FlutterPusher pusher = FlutterPusher("XXXXXXXXXXXXXXXX", options,
        enableLogging: true,
        onConnectionStateChange: (ConnectionStateChange x) async {
          print(x.currentState);
          
        },
        onError: (ConnectionError y) => {print(y.message)});
    
    Echo echo = new Echo({
      'broadcaster': 'pusher',
      'client': pusher,
    });
    
    echo.channel('public').listen('EssaiEvent', (e) {
      print(
          'BIEN REUSSI')
    });