Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random disconnect #114

Open
Cocss opened this issue Mar 12, 2023 · 3 comments
Open

Random disconnect #114

Cocss opened this issue Mar 12, 2023 · 3 comments

Comments

@Cocss
Copy link

Cocss commented Mar 12, 2023

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

@Inzaniity
Copy link

Inzaniity commented Mar 15, 2023

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()

@WrithemTwine
Copy link

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).

@Inzaniity
Copy link

There is this PR which is also resolving this as it seems: TwitchLib/TwitchLib.Communication#17

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants