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)
{
try
{
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 };
SendJoinMessage(Password);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
… 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 :twitch.tv/commands”);
SendIrcMessage(“CAP REQ :twitch.tv/tags”);
}
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, Chat & Chatbots | Twitch Developers only sends PASS
then NICK
never USER
1 Like
tetyys
July 28, 2021, 11:39am
5
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
Mm2PL
July 28, 2021, 1:57pm
6
From my observations USER
does exactly nothing.
> PASS xd
> NICK justinfan1234
< :tmi.twitch.tv 001 justinfan1234 :Welcome, GLHF!
< :tmi.twitch.tv 002 justinfan1234 :Your host is tmi.twitch.tv
< :tmi.twitch.tv 003 justinfan1234 :This server is rather new
< :tmi.twitch.tv 004 justinfan1234 :-
< :tmi.twitch.tv 375 justinfan1234 :-
< :tmi.twitch.tv 372 justinfan1234 :You are in a maze of twisty passages, all alike.
< :tmi.twitch.tv 376 justinfan1234 :>
> USER justinfan1234 8 * :justinfan1234
The RFC 2812 spec says that:
3.1.3 User message
Command: USER
Parameters: <user> <mode> <unused> <realname>
The USER command is used at the beginning of connection to specify
the username, hostname and realname of a new user.
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
system
Closed
August 27, 2021, 2:00pm
8
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.