websockets-rs / websockets-rs/rust-websocket

localhost does not resolve

Open
#135 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
1.6k
Forks
225
PR merge metrics
No merged PRs in 30d

Description

I tried to open an async connection to a server running locally at ws://localhost:4000 and received the following error:

IoError(Error { repr: Os { code: 61, message: "Connection refused" } })

However, the following work:

  • opening an async websocket connection to ws://127.0.0.1:4000. So my code connects once DNS is resolved.
  • opening an async websocket connection to ws://echo.websocket.org. So websocket DNS resolution does work in some cases.
  • opening a synchronous websocket connection to ws://localhost:4000. So local DNS resolution works but only for synchronous connections.
  • opening an async HTTP connection to 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.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the async websocket connection to ws://localhost:4000 and compare it with ws://127.0.0.1:4000, the synchronous websocket path, and the Hyper 0.11 HTTP path. Trace the async DNS resolution entry point and determine why localhost differs; done means async websocket connections resolve localhost successfully without manual substitution.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
networking
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.