Error on Socket Connection by the Host

Sometimes i face errors like socket error code 10054 Connection reset by peer.

you guys know how to fix it? it’s only catch in read(recv) step…

I’m doing in C# … i want to retry it in BeginConnection step. but it just only send error msg in read.

give me some inspiration bb

Could be many things.

Tough to help without knowing what you are trying to do. And what your code looks like.

… constructor

public ChatClient(string Ip, int Port, string UserName, string Password ,string Channel)
this.UserName = UserName;
this.Channel = Channel;

            TcpClient = new TcpClient(Ip, Port);
            NetworkStream Stream = TcpClient.GetStream();
            InputStream = new StreamReader(Stream);
            OutputStream = new StreamWriter(Stream) { NewLine = "\r\n", AutoFlush = true };
        catch (Exception e)

… SendJoinMessage(string Message)

private void SendJoinMessage(string Password)
SendIrcMessage("PASS " + Password); //
SendIrcMessage("NICK " + UserName);
SendIrcMessage(“USER " + UserName + " 8 * :” + UserName);
SendIrcMessage(“JOIN #” + Channel);
SendIrcMessage(“CAP REQ”);
SendIrcMessage(“CAP REQ”);

send or read is just trying to read or write use in StreamReader/Writer in asynchronous Method…

10054 socket error message seems like go wrong in first handshake or in connect moment,

but i only catch it in StreamWriter.ReadLineAsync()… at that moment.

how can i verify the connection is valid?

I already try to do in dataAvaliable or ConnectAsync…
(only i can do is maybe convert it in to use callback or delegate event)

i think many others don’t create socket connection in constructor…
(it can’t use async/await/ task)

anyway… the question is how can i verify the connection is valid?

Don’t send USER I expect that is messing with things

The guide, IRC Guide | Twitch Developers only sends PASS then NICK never USER

1 Like

this forum is not for general programming support. despite you using pretty old framework classes and methods for TCP communication, make sure you are connecting to non-ssl IP:Port as you don’t have support for that in your code.

you can verify if connection is valid by sending a PING

1 Like

From my observations USER does exactly nothing.

> PASS xd
> NICK justinfan1234
< 001 justinfan1234 :Welcome, GLHF!
< 002 justinfan1234 :Your host is
< 003 justinfan1234 :This server is rather new
< 004 justinfan1234 :-
< 375 justinfan1234 :-
< 372 justinfan1234 :You are in a maze of twisty passages, all alike.
< 376 justinfan1234 :>
> USER justinfan1234 8 * :justinfan1234

The RFC 2812 spec says that:

TMI doesn’t support user modes properly nor does it have realnames.

1 Like

Last time I sent the wrong USER I got dc’ed so that behaviour seems to have changed. shrugs
But it’s been a looooong time since I tried sending mismatched data.
I was thinking of NICK

I advised removing USER since the docs don’t mention sending it and wanted to rule it out for OP

Twitch doesn’t follow the RFC. TMI is a bunch of go scripts wearing a trench coat pretending to be IRC and speaking French.

1 Like

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