Unable to connect to irc.chat.twitch.tv:6667

Hi everyone.
I was trying to write a script to display twitch chat in unity, but I was unable to connect to irc.chat.twitch.tv:6667, unity console returns “Server not responding” error.
What could be the reason? Is twitch blocking access requests from certain regions?

Part of my script here:
public async void ConnectToTwitch()
{
Debug.Log(“Connect start”);
tcpClient = new TcpClient();
await tcpClient.ConnectAsync(“irc.chat.twitch.tv”, 6667);

    streamReader = new StreamReader(tcpClient.GetStream());
    streamWriter = new StreamWriter(tcpClient.GetStream()) { NewLine = "\r\n", AutoFlush = true };

    await streamWriter.WriteLineAsync("PASS" + Token);
    await streamWriter.WriteLineAsync("NICK" + Token);

    Debug.Log("Connection successful");

    ReadMessage();
}

Thank you!

You could try irc.twitch.tv instead as the URL.

You could also try changing the port from 6667 to 80 or 443 (you should use 443 for security).

Half-width spaces are important.

await streamWriter.WriteLineAsync("PASS" + Token);
→await streamWriter.WriteLineAsync("PASS " + Token);

await streamWriter.WriteLineAsync("NICK" + Token);
→await streamWriter.WriteLineAsync("NICK " + "username");

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