aatxe / irc

the irc crate – usable, async IRC for Rust
Mozilla Public License 2.0
533 stars 98 forks source link

Your front-page example #214

Closed erikh closed 3 years ago

erikh commented 4 years ago

If ping_timeout is not set the connection to freenode will immediately timeout.

Sorry I don't have more bandwidth than to seagull. Perhaps next time! :)

cemeyer commented 4 years ago

Duplicate of #207 , I think.

erikh commented 4 years ago

Not precisely; I figured it out later. In the 0.14.0 crate, no ping timeout is being set. Quite literally setting this to any reasonable value (I used 180, the default in the source code) will work.

erikh commented 4 years ago

I am using Config::default() with a "default" struct and also configuration files; you can find my source code here (it's a mess, I'm new to rust, I'm sorry in advance)

https://code.hollensbe.org/erikh/robutt (it's my name and I like it)

cemeyer commented 4 years ago

Ah, my mistake, sorry. I am also new to rust!

I am also not sure how ::default() is supposed to work, or why this code does not set the 180 we might expect it to:

https://docs.rs/irc/0.14.0/src/irc/client/data/config.rs.html#571-582

My read of it is the Config struct derives the Default trait, which provides ::default(). The derived trait derives default values from the trait in the individual members. Default for ping_timeout: Option<u32> is None, so I'm surprised this doesn't work.

aatxe commented 4 years ago

@cemeyer Your understanding is correct. The issue here is that the default ping timeout is 10 seconds, not 180 seconds as @erikh has suggested. This is too low for freenode's connection process which is... extremely slow for whatever reason. The confusion is between ping_timeout and ping_time which represent different things. ping_time is supposed to indicate how frequently the client sends a ping, and the timeout is how long it will wait to receive a response before considering it a failure.

This problem is exacerbated by the fact that the migration to tokio 0.2 seems to have stopped using ping_time altogether, instead setting the interval to half of the timeout (meaning that the client is, by default, sending a ping every five seconds).

erikh commented 4 years ago

I've examined this a little; I think the proxy scan + VERSION CTCP freenode immediately sends are the issue, perhaps not making the CTCP ping time (a TCP timeout should be different) something that can affect connection until after the MOTD is sent would be best? Maybe an option?

erikh commented 4 years ago

And before you say it; I agree, computers are terrible. :P

aatxe commented 3 years ago

I'm going to close this with the understanding that #222 resolved it, but please let me know if I'm missing something and that isn't the case.

cemeyer commented 3 years ago

Seems plausible to me, thanks!