Open Cocss opened 1 year ago
Probably the same issue as in #111 which I also still encounter. Someone there said they got around it but I had no success yet.
I tried to implement what they suggested as follows:
private static async void OnPubSubServiceError(object sender, OnPubSubServiceErrorArgs e)
{
[...]
await Task.Delay(30000);
CreatePubSubListenEvents();
TwitchPubSub.Connect();
}
private static void CreatePubSubListenEvents()
{
TwitchPubSub.ListenToVideoPlayback(Settings.Settings.TwitchChannelId);
TwitchPubSub.ListenToChannelPoints(Settings.Settings.TwitchChannelId);
}
private static void OnPubSubServiceConnected(object sender, EventArgs e)
{
TwitchPubSub.SendTopics(Settings.Settings.TwitchAccessToken);
}
Either I'm dumb and did not do as they described or the issue still exists.
And the exceptions is always
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions) at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken) at TwitchLib.Communication.Clients.WebSocketClient._Open() at Songify_Slim.Util.Songify.TwitchHandler.
d__28.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() at System.Threading.ThreadPoolWorkQueue.Dispatch()
Same issue happened to me, and it's in the log as a 'reconnect', then nothing.
I found this:
https://github.com/TwitchLib/TwitchLib.PubSub/blob/master/TwitchLib.PubSub/TwitchPubSub.cs#L675
case "reconnect": _socket.Close(); break;
Currently, there isn't any 'reconnect' handling nor notification beyond the logger, that I'm aware. I'm currently trying to figure out how to respond to a disconnect/reconnect. Maybe parse the log message, though the most efficient (but cumbersome to match library updates) would be to pull-in the code (attribution of course), and add-on reconnect handling.
At the least, the 'reconnect' message could fire the 'OnDisconnect' event to at least tell us we need to manage reconnecting PubSub.
(I purposely don't directly code contribute so my code references a framework API, in a reliance sort of way. I've sometimes had to pull code to add some corrections- like http disruption exceptions not in 'try/catch' library code, add some features or add another service).
There is this PR which is also resolving this as it seems: https://github.com/TwitchLib/TwitchLib.Communication/pull/17
Can anyone help me understand why Pubsub is constantly disconnected without any errors, everything just stops working, it doesn't listen to 1 event. What am I doing wrong? lol