Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions packages/transport-circuit-relay-v2/src/transport/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export class CircuitRelayTransport implements Transport<CircuitRelayDialEvents>
const destinationId = destinationAddr.getComponents().find(c => c.code === CODE_P2P)?.value

if (relayId == null || destinationId == null) {
const errMsg = `ircuit relay dial to ${ma.toString()} failed as address did not have both relay and destination PeerIDs`
const errMsg = `circuit relay dial to ${ma.toString()} failed as address did not have both relay and destination PeerIDs`
this.log.error(`c${errMsg}`)
throw new DialError(`C${errMsg}`)
}
Expand All @@ -165,7 +165,16 @@ export class CircuitRelayTransport implements Transport<CircuitRelayDialEvents>
})

options.onProgress?.(new CustomProgressEvent('circuit-relay:open-connection'))
relayConnection = await this.components.connectionManager.openConnection(relayPeer, options)

try {
// Dial the concrete relay address first. Peer-id dialing can fail with
// NoValidAddressesError in nested relay/WebRTC flows if candidate
// address discovery/filtering returns no dialable addresses.
relayConnection = await this.components.connectionManager.openConnection(relayAddr, options)
} catch (err: any) {
this.log.error('opening direct relay connection to %a failed, falling back to peer dial for %p - %e', relayAddr, relayPeer, err)
relayConnection = await this.components.connectionManager.openConnection(relayPeer, options)
}
} else {
options.onProgress?.(new CustomProgressEvent('circuit-relay:reuse-connection'))
}
Expand Down
Loading