pratikbaid3 / flutter_client_sse

Dart package to help consume SSE API. Consumes server sent events by returning parsed model of the event, id, and the data
https://pub.dev/packages/flutter_client_sse
MIT License
40 stars 41 forks source link

Error on unsubscribe #4

Closed aaumond closed 1 year ago

aaumond commented 2 years ago

Hello @pratikbaid3,

If I subscribe on SSE webservice (via subscribeToSSE static method), then I unsubscribe (via unsubscribeFromSSE static method) and finally I re-subscribe, an error occured :

flutter: ---ERROR---
flutter: Connection closed while receiving data

I think the problem comes from this line of code (line 35) because the subscription is not killed in unsubscribeFromSSE method : response.asStream().listen()

Thanks in advance. Anthony

pratikbaid3 commented 2 years ago

Looking into it. Thanks for identifying it @aaumond.

aaumond commented 2 years ago

hello @pratikbaid3 , did you find a solution?

pratikbaid3 commented 2 years ago

Hi @aaumond. I couldn't find time to get working on this just yet. Will hopefully fix this over the weekend. Thanks.

TomBeckett commented 2 years ago

Hey @pratikbaid3 did you get a chance to look at this?

pratikbaid3 commented 1 year ago

Hi @TomBeckett @aaumond. This issue is now fixed in the latest pre-release build https://pub.dev/packages/flutter_client_sse/versions/2.0.0-beta.1

Thanks and Regards

miguelpruivo commented 1 year ago

@pratikbaid3 this is still an issue on 2.0.0. I'm getting it after canceling the subscription. You need to close the streamController.close() first before closing the client.

pratikbaid3 commented 1 year ago

Hi @miguelpruivo . Can you share the logs if possible?

miguelpruivo commented 11 months ago

Hi @miguelpruivo . Can you share the logs if possible?

Hi, just by using:

SSEClient.unsubscribeFromSSE();

I always seem to get:

ClientException: Connection closed while receiving data