Open alex-shapiro opened 7 years ago
Good catch! It's probably this code: https://github.com/cyderize/rust-websocket/blob/master/src/client/builder.rs#L800
Instead of calling next()
you should create a TcpStream
with that iterator and then turn it into an async one with the async TcpStream
's API.
That means the DNS lookup would be done synchronously, right?
hmm... that's a good point. I wonder how hyper 0.11 is doing it
Looks like Hyper wraps a synchronous DNS call inside a future: https://github.com/hyperium/hyper/blob/master/src/client/dns.rs#L52.
We can try looping over the ToSocketAddr
in the future (make one async DNS call, if that fails try again). This would get a really complicated type though.
I tried to open an async connection to a server running locally at
ws://localhost:4000
and received the following error:However, the following work:
ws://127.0.0.1:4000
. So my code connects once DNS is resolved.ws://echo.websocket.org
. So websocket DNS resolution does work in some cases.ws://localhost:4000
. So local DNS resolution works but only for synchronous connections.http://localhost:4000
with Hyper 0.11. Does Hyper 0.11 use a different Tokio primitive to resolve DNS?I'm not exactly sure what's going on. It's not a big deal - I'm manually resolving localhost to 127.0.0.1 - but I'm kind of curious.