glacasa / Mastonet

C# Library for Mastodon
MIT License
225 stars 37 forks source link

Streaming robustness #89

Open instantiator opened 1 year ago

instantiator commented 1 year ago

I've encountered some issues with streaming. After a while, things stop coming through - and I suspect it's because the stream is closing in some way, but at the moment there's not an easy way to see that.

instantiator commented 1 year ago

👆 https://github.com/glacasa/Mastonet/pull/90 is a(n untested) proposal that might increase the robustness of the streaming classes. It adds options to detect timeout from the stream (ie. if there's no comment or event/data received for too long), and to optionally restart the stream if that occurs (or throw a TimeoutException if not restarting).

What do you think?

instantiator commented 1 year ago

I've done some further experimentation, and I'm pretty convinced now the issue I've seen is not in Mastonet after all*.

However, adding a little defensive code around the stream may still be helpful - if, say, it's closed at either end for some unexpected reason it's probably still good to be able to re-open it again.

*I failed to keep a reference to the Task that was running the streaming. I suspect it was silently garbage collected.