Skip to content

Conversation

@andersk
Copy link

@andersk andersk commented Sep 25, 2019

No description provided.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
pub fn resolve_addr(
addr_str: &str,
) -> impl Future<Item = SocketAddr, Error = Box<dyn std::error::Error + 'static>> {
// TODO: resolve asynchronously
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really needed to be resolved at connecting time, not just once at argument parsing time?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is: when running websocat as a daemon, it shouldn’t need to be restarted just because a remote DNS name changed. Additionally, one might want to point websocat at a service using DNS load balancing.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tardiness in DNS reply may not only delay establishing a new connection, but also suspend all unrelated neighbour connections - websocat is mostly single-threaded.

Copy link
Author

@andersk andersk Sep 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, until we get async DNS, that’s a tradeoff. But this design allows the user to make that tradeoff. They can always choose to provide an IP address, or to install a local caching resolver (which will do the job much better than we would—sharing the cache between all apps on the system, respecting TTLs, and so on).

.to_socket_addrs()
.and_then(|mut addrs| {
addrs
.next()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be a welcome extension.

@vi
Copy link
Owner

vi commented Sep 25, 2019

Note: I remember doing similar change (but more elaborate, supporting multiple addresses and fast fallback) in "websocket_lowlevel" branch where websocat 2.0 is cooking.

Maybe it's worth backporting it to websocat 1...

@vi vi force-pushed the master branch 2 times, most recently from 00113dc to 9ab5e4a Compare May 17, 2022 21:20
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

Successfully merging this pull request may close these issues.

2 participants