C# IRC chat bot not connecting

Hello, for the past few months my bot has not worked. When i try to run it, it will stop responding, I’ve checked over the code more times than i can count and everything seems to be okay. After a few minutes of the code running it will crash and give this error: http://prntscr.com/dtjbp2 or http://prntscr.com/dtjc3z… Here are pastes of my code, and hopefully someone can tell me what happened… It was running fine, i changed NO code and then it just stopped working… Has twitch changed how to connect through IRC?

It stopped working around november 25th and hasnt worked since.

Form1.cs http://pastebin.com/t5Ev3CVa

IniFile.cs http://pastebin.com/xB8hFsvp

IrcClient.cs http://pastebin.com/B72sYiDb

program.cs http://pastebin.com/DeayYE8x

Sorry for the very messy code…

Thanks for all the help! I really appreciate it! :slight_smile:

You’re intercepting and responding to PING commands, right? I see the PingResponse method, but I don’t see where you’re actually getting the PING command from the server.

I thought i was… didn’t realize i wasn’t… But it shouldn’t matter either way, should it? It should still connect, but disconnect after a while because it isn’t sending a “PONG” to twitch.

Haven’t looked through everything but try removing the line:
outputStream.WriteLine("USER " + userName + " 8 * :" + userName);

PASS(oauth) and NICK should be sufficient I believe.

Beyond that, set up a breakpoint then stepthrough each step to see where you get the error, that may help you see what exactly is throwing it.

Dallas is also correct, don’t see any spot where you read the PING and then call that function in your msg() function in Form1.cs

Removed the line and same thing is still happening. I’ve tried setting breakpoints and the error is when it’s trying to connect. I’ve set up a try catch statement and throws an error every time, so I’m not sure what is happening… I thought it would be my firewall, but i disabled that and same thing still occurs. And yeah, i realize that about the ping response now, I will fix that.

Thanks :slight_smile:

Okay, took a further look.

The problem is this line in IrcClient.cs:

outputStream.WriteLine("NICK " + userName);

You have two declared variables; username and userName. Change that line to the below and it should work now:

outputStream.WriteLine("NICK " + username);

Problem isn’t there… Tried it again, still nothing… I set break points there and didn’t even break there, so something goes wrong before that.

It stops at this line: tcpClient = new TcpClient(ip, port);

Works fine before that, but then just disappears and doesnt break at the next part

Hmm yeah, might be something on your end blocking it - I copied your code on my end and it worked after the changes I mentioned above (even before it never broke on the tcpClient connection.)

This is the IrcClient.cs I have now, but I’ve only changed what I mentioned above.

I would suggest checking out another existing IRC library to see if that one works as intended - I can’t think of anything at the moment of what else could block it on your end.

Hmmm… I’ve tried using someone else’s code and same thing happened… Not sure what could be blocking it though… I’ll try it on another computer, and if that doesn’t work i’ll try on another connection. Thanks for your help

Okay it was actually my end… My router was blocking all IRC connections. Thanks

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.