TwitchLib / TwitchLib.PubSub

PubSub component of TwitchLib.
38 stars 52 forks source link

PubSub Service Error #96

Closed A5ho9999 closed 1 year ago

A5ho9999 commented 3 years ago

Hello, I'm having an issue with PubSub that I setup yesterday. It works at the start and then it posts and error causing it to stop working. I'm using the suggested MessagesAllowedInPeriod and ThrottlingPeriod amounts given in the Example. It seems to throw the error when no events have triggered in a certain amount of time. When I started it was connected up to 3 minutes before the error was given and another lasted up to 20 minutes with Followers & Bit events going on but when they stopped it gave the error 10 minutes after. There was only max of 150 people watching the stream and max of 10 talking at any time so I don't see a reason for the Throttler to get trigger.

PubSub Service Error

System.OperationCanceledException: The operation was canceled.
   at System.Collections.Concurrent.BlockingCollection`1.TryTakeWithNoTimeValidation(T& item, Int32 millisecondsTimeout, CancellationToken cancellationToken, CancellationTokenSource combinedTokenSource)
   at System.Collections.Concurrent.BlockingCollection`1.TryTake(T& item, Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Collections.Concurrent.BlockingCollection`1.Take(CancellationToken cancellationToken)
   at TwitchLib.Communication.Services.Throttlers.<StartWhisperSenderTask>b__29_0()

PubSub Service Error

System.OperationCanceledException: The operation was canceled.
   at System.Collections.Concurrent.BlockingCollection`1.TryTakeWithNoTimeValidation(T& item, Int32 millisecondsTimeout, CancellationToken cancellationToken, CancellationTokenSource combinedTokenSource)
   at System.Collections.Concurrent.BlockingCollection`1.TryTake(T& item, Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Collections.Concurrent.BlockingCollection`1.Take(CancellationToken cancellationToken)
   at TwitchLib.Communication.Services.Throttlers.<StartSenderTask>b__28_0()
Syzuna commented 3 years ago

There is no way to setup a throttler with Pubsub. The Throttlers are soley Chat Client related. how did you get them setup in the first place bcs the TwitchPubsub constructor doesnt allow to override anything in that regard

A5ho9999 commented 3 years ago

I'm using the Both TwitchClient and TwitchPubSub, Client for Chat and PubSub for Bit/Follow/Reward Events. The error is given from the OnPubSubServiceError Event though. So I don't know what else to tell you. I simply used the example setup that was provided by JayJay

Syzuna commented 3 years ago

ok so could you also listen to OnPubSubServiceClosed? I have the feeling you get disconnected by Twitch for some reason, and we didnt handle some exceptions properly so that they get propagated up. Because the only 2 spots where the TokenSource used receives a cancel request is in a WebsocketMessageType.Close scenario or if you call Disconnect yourself.

Edit: just saw a third spot and that would be if the socket itself doesnt get a PONG back if it sends a PING, then it closes the socket as well and would cancel the TokenSource

Syzuna commented 3 years ago

and yeah dw was just a bit confused about Throttler settings in Pubsub. all good

A5ho9999 commented 3 years ago

I am listening to all the connection events. I'm yet to have the Closed Event trigger at all, I'll start to listen to the OnLog and see if that gives any extra information if that'd help resolve the issue.

Syzuna commented 3 years ago

Yeah that would be nice. Because right now I cant explain myself why the TokenSource would issue a cancellation here if you also dont get disconnected

A5ho9999 commented 3 years ago

It's been okay so far, getting PONG in the Log. Will have to wait and see what happens when the stream starts, will close this if it's okay throughout the stream.

A5ho9999 commented 3 years ago

Stream went okay, error didn't appear again strangely as the only thing that was different was the OnLog being added.