I have tried several times in several ways to respond to the PING message, which has not happened until last month has now become a constant headache.
The Irc Class:
http://pastebin.com/8LZTZrHC
I have tried several times in several ways to respond to the PING message, which has not happened until last month has now become a constant headache.
The Irc Class:
http://pastebin.com/8LZTZrHC
Woah, you want us to debug 400 lines of code? Try to make a minimal example of what is not working please
How quickly is it disconnecting? Edge servers occasionally restart too, requiring a reconnect from clients connected to it. A simple PONG\r\n
every 5 minutes will keep the chat server happy.
I’d say go with 3ventic’s suggestion. I don’t know anything about C# but does this work?
String message = inputStream.readMessage(); Console.WriteLine(message); if (message.StartsWith("PING")) { sendIrcMessage("PONG :tmi.twitch.tv"); }
or
String message = inputStream.ReadLine(); Console.WriteLine(message); if (message == "PING :tmi.twitch.tv") { sendIrcMessage("PONG :tmi.twitch.tv"); }
void PingSender()
{
while (true)
{
try
{
sendIrcMessage("PONG\r\n");
Thread.Sleep(configs.TIME_INTERVAL_THREAD * 2);
}
catch (Exception)
{
Console.WriteLine("erro ping");
}
}
}
Solved (i think) using a thread with 2 minutes interval, apparently 5 minutes of delay is not enough. If someone else have same or similar code try this.
I’d move the Thread.Sleep
out of the try/catch just in case there is ever a situation where message cannot be sent. Otherwise, that loop will eat 100% of your CPU if for whatever reason that method fails. That, or just add another Thread.Sleep(50)
in your catch.
By any chance, are you hosting from Azure? Someone was using a bot I work on and after some digging discovered that Azure closes out connections that are not kept active within 4 minutes (I believe it was 4 minutes) so had to enable the PING/PONG more often for that person late last year.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.