libp2p / libp2p/rust-libp2p

Websocket transport (with `tokio`) doesn't work on Android

Open
#5,672 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
5.6k
Forks
1.3k
Avg merge
8h 47m
Merged PRs (30d)
19

Description

Summary

Since the websocket transport relies on the DNS transport, it's affected by the same issue as its dependency (#2064) and fails to work on Android. For DNS, the issue can be mitigated by providing custom libp2p_dns::ResolverConfig and libp2p_dns::ResolverOpts instead of trying to read the system configuration, but this is not currently possible for websockets, since the websocket builder (for tokio) creates a DNS transport instance internally and doesn't allow any customization:
https://github.com/libp2p/rust-libp2p/blob/4192fc3daed761a127e6986a75e016d483846555/libp2p/src/builder/phase/websocket.rs#L126-L135

Expected behavior

SwarmBuilder::with_websocket successfully configures the websocket transport on Android.

Actual behavior

SwarmBuilder::with_websocket returns an error due to an internal DNS issue where /etc/resolv.conf can't be found.

Relevant log output

No response

Possible Solution

I'm not very familiar with the library’s internals, but the most straightforward solution appears to be to allow custom configuration for the internal DNS transport so the builder doesn’t attempt to read the system config. This could be achieved by introducing a libp2p_websocket::Config structure, similar to those used by other transports (e.g., TCP), with optional DNS configuration for creating the DNS transport instance. However, the DNS configuration should probably be only included when applicable, such as when using the tokio runtime, to avoid cluttering the interface.

Version

0.54.1

Would you like to work on fixing this bug ?

Maybe

Contributor guide

Open the contributing guide

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 at libp2p/src/builder/phase/websocket.rs around the referenced websocket builder code and trace how SwarmBuilder::with_websocket creates the tokio DNS transport. Review the existing libp2p_dns ResolverConfig and ResolverOpts customization described in issue #2064; done means the builder can configure websocket transport successfully on Android without requiring /etc/resolv.conf.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.