Established Connection Aborted

I keep getting this error every time my IRC bot is connected. This just started happening this morning after running this bot for over a month now.

Additional information: Unable to read data from the transport connection: An established connection was aborted by the software in your host machine.

What would be causing such an error?

Full Error:

System.IO.IOException was unhandled
HResult=-2146232800
Message=Unable to read data from the transport connection: An established connection was aborted by the software in your host machine.
Source=System
StackTrace:
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadLine()
at twitch_irc_bot.IrcClient.ReadMessage() in c:\Users\Lance\Documents\GitHub\bot_csharp\fembot\irc_bot\IrcClient.cs:line 112
at twitch_irc_bot.Program.Main(String[] args) in c:\Users\Lance\Documents\GitHub\bot_csharp\fembot\irc_bot\Program.cs:line 30
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
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.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.Net.Sockets.SocketException
HResult=-2147467259
Message=An established connection was aborted by the software in your host machine
Source=System
ErrorCode=10053
NativeErrorCode=10053
StackTrace:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
InnerException:

Typically this happens when you get disconnected. That can be for a variety of reasons, but often it’s because you aren’t responding to server pings in a timely manner, or your message buffer isn’t being cleared fast enough.

See I find that very weird. Like I said this has been working for a month no problems what so ever. It doesn’t seem to be happening anymore. It’s not like it is under a heavy load. It’s actually very idle at the moment. I’ve looked on stack overflow and a few other websites. It says it could be my firewall killing the connection. So I disabled my firewall and this is still happening. I don’t know how to debug this.

it happened to my bot as well a few hours ago for the first time. so, i assume it was something on twitch’s end.

Yep, just checked my logs and it looks like it’s happening to a large portion of our connections too.

1 Like

How do I compensate for this error though. I don’t want my bot to just crash when something like this happens.

Have you tried rotating the connection ip?

1 Like

I’m not sure exactly how to do that, but this hiccup was immediately terminating the connection so I’m not sure rotating the IP would have solved the problem. It is definitely something to look into though.

If it’s a firewall issue, or a server listener issue switching ips will connect with a server that is (theoretically) not impacted if it’s a transient issue.

it stopped happening for me after the second time.
You could catch the exception and create a new one if it’s still happening to you

@tournymasterbotCurse Does Twitch have more than one thing I can connect to. Currently I’m connected to irc.twitch.tv:6667

That’s an idea thanks @Freddy

you can find all available IPs here: https://api.twitch.tv/api/channels/lirik/chat_properties (Lirik’s channel is just an example)

1 Like

@Freddy do you IP rotate in your bot. If so could you show me how you do it. Or link me to a reference.

i don’t. i simply connect to irc.twitch.tv

One more stupid question. What’s the difference between websocket server and websocket server 1.0

Hi Tance,

Would you mind providing us with the IP that you resolve to when you connect to irc.twitch.tv?

Alternatively you can switch out (as others have mentioned) the hostname for the direct IP, which can help narrow down issues. If you cannot connect at all, it is possible your DNS resolver is returning stale data, which can be solved with "ipconfig /flushdns"

Websockets are a method of communication over a TCP connection, but you shouldn’t need them for your bot.

1 Like

@xangold I didn’t check in time when the error was occurring. It started happening around 2AM that morning and seemed to resolve itself around 5AM.

EDIT: This is the IP I was resolving to. - RemoteEndPoint {192.16.64.45:6667} System.Net.EndPoint System.Net.IPEndPoint}

I went ahead and built in an IP rotatory into my bot and I have yet to encounter this error again. If you would like I can revert back to the old way I was connecting and provide you with the IP that it resolved to if the error would happen to happen again.

It seems to be happening right now the IP is resolving to

tcpClient.Client.RemoteEndPoint {192.16.64.155:6667} System.Net.EndPoint {System.Net.IPEndPoint}

EDIT: I have a theory. Could I be getting globally banned my bot connects to multiple channels. 9 to be exact. I send these commands on startup.

_outputStream.WriteLine("PASS " + oAuth);
_outputStream.WriteLine("NICK " + userName);
_outputStream.WriteLine(“CAP REQ :twitch.tv/membership”);
_outputStream.WriteLine(“CAP REQ :twitch.tv/tags”);
_outputStream.WriteLine(“CAP REQ :twitch.tv/commands”);

Do these messages count towards my global limit?

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