braverhealth / phoenix-socket-dart

Cross-platform and stream-based implementation of Phoenix Sockets
https://pub.dev/packages/phoenix_socket
BSD 3-Clause "New" or "Revised" License
73 stars 37 forks source link

Await for a successful connection to the websocket before listening to messages #76

Closed miguelcmedeiros closed 4 months ago

miguelcmedeiros commented 4 months ago

Similar to issues (issue 1 and issue 2) reported in web_socket_channel package.

When the websocket connection is created and there's an exception thrown at this point we won't be able to catch it, leaving the client in an unrecoverable state (i.e. since the exception is not caught, the websocket artefacts are not properly cleared up).

socket.ready will complete with an error in case something goes wrong during WebSocketChannel.connect().

It's not an obvious API, but it seems to be the way to go with this package.

miguelcmedeiros commented 4 months ago

@matehat the integration sockets tests are failing. I will investigate what's happening there and let you know if I need help with them.

matehat commented 4 months ago

Great investigation! Thanks @miguelcmedeiros for your work :)