Having trouble connecting/reading messages in .Net

I am using WebSocketSharp to connect to the chat.

When I connect via ws://irc-ws.chat.twitch.tv:80, I can send messages, but no messages sent by other users are being returned.

When I try to connect via ws://irc.chat.twitch.tv:6667, as suggested in the documentation, I get an error.

Fatal|WebSocket.doHandshake|Not a WebSocket handshake response.

So, working with the url that works, I can send messages just fine and they appear in my channel. (I am joining the channel all in lowercase)

This code resides in my OnConnected handler and is triggered and works successfully with the irc-ws.chat.twitch.tv endpoint.

socket.Send(RFC2812Commands.Password(TwitchSettings.Default.BotOAuthToken));
socket.Send(RFC2812Commands.Nickname(TwitchSettings.Default.BotUsername));

socket.Send("CAP REQ twitch.tv/membership");
socket.Send("CAP REQ twitch.tv/commands");
socket.Send("CAP REQ twitch.tv/tags");

if (autoJoinDefaultChannel)
{
        JoinChannel(TwitchSettings.Default.TwitchChannelName);
}

I have an OnMessage handler set up, but any time another users posts to the chat, I do not get messages. However, posting a message from my code will show the message in chat.

Make sure the channel name you’re joining is prepended with # and all lowercase. Not sure if the JoinChannel method is doing all of that for you or not. :slight_smile:

1 Like

DOH!

Message sending did the #channel, but joining did not. It’s working now. Thank you so much!

Also irc.chat.twitch.tv (as opposed to irc-wc.chat.twitch.tv) is not a websocket endpoint, it’s normal TCP socket.

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