when trying to diagnose the problem a few days ago I vibed this:
<https://gitworkshop.dev/danconwaydev.com/ngit/tree/timeout-testing/timeout_test>
what I found was that the connection was failing early (often <500ms but always <1s) whereas nak took a bit longer but succesfully estalished a connection.
sometimes try_connect would return Ok(()) but relay.is_connected() would return false.
When nak couldnt establish a connection try_connect seemed to honour the specified timeout instead of failing quickly.
I ended up building in auto-retry that retires after an ever increasing delay up until the timeout. See src/lib/client.rs line 773-842. What I found with this is it would fail quickly everytime but never, in my limited testing, did it successfully connect on subsiquent attempts.
I was wondering whether try_connect() was picking up some sort of unexpected service respose that nak was ignoring but rust-nostr saw as a failure. I stopped getting the failures before I could dig any deeper and I haven't had any since.
I did all of this on rust-nostr v0.43. The tip of master is now on v0.44 (but i hadn't pushed it when nostr:nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8g2lcy6q last built ngit from master so his failures would be using v0.43)