kakajansh / echo

Laravel Echo for your Flutter apps.
MIT License
108 stars 70 forks source link

Flutter + Laravel Websocket + Pusher Replacement (Valet Secure) #42

Closed lambasoft closed 3 years ago

lambasoft commented 3 years ago

I'm using Beyondco Larevel Websockets on my Laravel Backend, and using pusher_client and laravel_echo on my Flutter frontend.

I've been trying to connect from my ios simulator into my Laravel Backend host, which is using valet secure, but failing.

My Flutter connections:


PusherClient getPusherClient(String token) {
  PusherOptions options = PusherOptions(
      host: 'my-local-server.test',
      wsPort: 6001,
      wssPort: 6001,
      cluster: DotEnv.env['PUSHER_APP_CLUSTER'],
      encrypted: true,
      auth: PusherAuth('https://my-local-server.test/api/broadcasting/auth',
          headers: {'Authorization': 'Bearer $token'})
  );

  return PusherClient(DotEnv.env['PUSHER_APP_KEY'], options,
      enableLogging: true, autoConnect: false);
}
pusherClient = getPusherClient(token);
pusherClient.connect();
pusherClient.onConnectionStateChange((state) {
  print(
      "previousState: ${state.previousState}, currentState: ${state.currentState}");
});
pusherClient.onConnectionError((error) {
  print(error.message);
});

From https://my-local-server.test/laravel-websockets I never see the requests from Flutter, but if I fire an event from my Laravel backend, it gets logged.

Please help me with what's wrong in my setup, why I can't connect to my SSL valet server running laravel-websocket from my Flutter application.

fixer112 commented 3 years ago

run php artisan serve. and instear of using 127.0.0.1:8000 use 10.0.2.2:8000 on ur flutter

kakajansh commented 3 years ago

Maybe related with pusher_client not able to connect local pusher server. Please take a look how to Resolve Common Issues. Closing for now, feel free to open new issue if not resolved.