Bot getting stuck on inputStream

The bot works at first but randomly it freezes at

    public string readMessage()
        string message = inputStream.ReadLine(); //Here
        return message;

Ive tried to make the program wait and debug but it stops there and wont respond until
i reconnect my bot which is really annoying

It “freezes” because it is waiting for a line to arrive. If the server isn’t sending anything at the moment, your bot will wait until the server has something to send again. Consider reading the messages asynchronously.

But the problem is that the bot recives messages at first then just stops even if im still chatting the bot wont recive any of it until i reconnect the bot.

How quickly? Are you replying to PINGs with PONGs appropriately?

it stops in about 10-20 seconds

hmmm i might check if im ping ponging right

the bot gets disconnected before twitch pings me :confused:

Hey, it would perhaps be helpful if you’d show some more code of what you’re trying to do.

Some questions:

  1. Are you connecting and logging in properly?
  2. Do you receive messages from the channel at all?
  3. What do you mean by freezing? Normally it should cause exceptions if trying to read from a closed stream.


I’m going to have to agree with this. You need to make your reading code in a separate thread if you want the program to accept input on the main thread.

I am going to have to agree with @3ventic

i am not the greatest of programmers but your code should be along the lines of

var message = await inputStream.ReadLine();
return message;

i am thinking the reason you only get the first line is because it only execute once. but you will need to async the method because it will lock up your UI.

I do get messages for the first 15 seconds but then it stops at the part where it recives from the server

At this point I don’t think this makes much sense without showing more of the code. Otherwise it’s just a guessing game.

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