Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unexpected EOF in tokio_demo example #237

Open
fenhl opened this issue May 7, 2021 · 4 comments
Open

unexpected EOF in tokio_demo example #237

fenhl opened this issue May 7, 2021 · 4 comments

Comments

@fenhl
Copy link

fenhl commented May 7, 2021

After making the tokio_demo example compile by replacing tokio::time::delay_for with tokio::time::sleep, it gives the following output:

we're connecting!
Error: reached an unexpected EOF

No messages are actually sent to Twitch chat.

@Bauxitedev
Copy link

I randomly get this as well, and I had to downgrade to Tokio 0.2 otherwise I'd get an error related to Tokio's reactor not running. But it seems unpredictable.

@Bauxitedev
Copy link

Update: as a temporary workaround, I use a simple spinloop that tries to connect at most once per second. So if the connection fails, it'll try again one second later, until it (randomly) succeeds.

use tokio::{join, time::delay_for}; //Using the Tokio runtime

...

loop {
        println!("connecting to twitch...");

        //Avoid spinning like a maniac when an error occurs repeatedly
        let minimum_loop_delay = delay_for(Duration::from_millis(1000));

        //Join the two futures together so we wait on them both concurrently
        match join!(twitch_loop(), minimum_loop_delay) {
            (Ok(()), _) => println!("connected to twitch!"),
            (Err(e), _) => println!("twitch conn. failed: {:?}", e),
        }
    }

@Bauxitedev
Copy link

Update2: it turns out if you change your password or enable 2FA, you get this error repeatedly and consistently until you generate a new OAuth2 key. Then it works like 90% of the time, the other 10% I just spinloop until it works, see my code above.

@halzy
Copy link
Collaborator

halzy commented Feb 25, 2022

The best I was able to reproduce was by passing in a bogus oauth token. The streams looked like so:

> CAP REQ :twitch.tv/membership
> CAP REQ :twitch.tv/tags
> CAP REQ :twitch.tv/commands
> PASS oauth:12345....XYZ
> NICK mrhalzy
< :tmi.twitch.tv CAP * ACK :twitch.tv/membership
< :tmi.twitch.tv CAP * ACK :twitch.tv/tags
< :tmi.twitch.tv CAP * ACK :twitch.tv/commands
< :tmi.twitch.tv NOTICE * :Login authentication failed

I suspect it's the last line that doesn't parse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants