Skip to content
This repository was archived by the owner on Feb 12, 2024. It is now read-only.
This repository was archived by the owner on Feb 12, 2024. It is now read-only.

Using the best address available #812

@jackkleeman

Description

@jackkleeman

It seems to me that if I have a peerinfo with two addresses of which one is successful, a call to dialbypeerinfo works only 50% of the time, if the 'good' address is attempted first. If the bad address is attempted first, I just get a dial error; I was under the impression that libp2p would try all options until one succeeds.
I have had this issue with addresses that totally fail, eg local addresses - the dial fails after a websocket creation timeout, which is pretty long! I also have it on addresses that somewhat fail, eg the websocket connection does not upgrade. At least in those cases I have a prompt failure, instead of a wait for timeout.

I believe the issue is in libp2p-swarm/transport.js, where at line 56 the result of multiaddrs.shift() is passed to next() which attempts to dial. This is done only once, so only the first multiaddr is dialled to. A comment makes it seem like the writer thought that all dials will happen in sequence. I think instead that it should loop over the multiaddrs attempting to dial them all and calling back with the first success.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugA bug in existing code (including security flaws)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions