Skip to content

Unable to holepunch from the local network to a Docker container #112

@louneskmt

Description

@louneskmt

Hey!

I am not able to connect to a DHT server running in a Docker container, from the same local network. To be clear, the Docker stack has its own Docker network, which lives in my home network. Here is a summary of the situation (I used @hyperswarm/doctor for the tests):

telegram-cloud-photo-size-4-5805510472735242539-y

Apparently, it may be because as both the clients and the server have the same external IP X.X.X.X, it tries to connect via LAN, but in reality the server is in a container with its own network.

Here is the full error, client-side
Waiting for node to be fully bootstrapped to collect info...

Node info:
- remote host: X.X.X.X
- remote port: 56888
- firewalled: true
- nat type: consistent

Connecting to test server...
Sending 32 bytes for the server to echo
/home/louneskmt/test/node_modules/.pnpm/@hyperswarm+dht@6.3.3/node_modules/@hyperswarm/dht/lib/connect.js:154
  const onabort = () => c.encryptedSocket.destroy(HOLEPUNCH_ABORTED())
                                                  ^

DHTError: HOLEPUNCH_ABORTED: Holepunch aborted
    at Holepuncher.onabort (/home/louneskmt/test/node_modules/.pnpm/@hyperswarm+dht@6.3.3/node_modules/@hyperswarm/dht/lib/connect.js:154:51)
    at Holepuncher.destroy (/home/louneskmt/test/node_modules/.pnpm/@hyperswarm+dht@6.3.3/node_modules/@hyperswarm/dht/lib/holepuncher.js:279:31)
    at Holepuncher._autoDestroy (/home/louneskmt/test/node_modules/.pnpm/@hyperswarm+dht@6.3.3/node_modules/@hyperswarm/dht/lib/holepuncher.js:267:31)
    at Holepuncher._consistentProbe (/home/louneskmt/test/node_modules/.pnpm/@hyperswarm+dht@6.3.3/node_modules/@hyperswarm/dht/lib/holepuncher.js:218:10)
Emitted 'error' event on NoiseSecretStream instance at:
    at WritableState.afterDestroy (/home/louneskmt/test/node_modules/.pnpm/streamx@2.12.5/node_modules/streamx/index.js:444:19)
    at NoiseSecretStream._destroy (/home/louneskmt/test/node_modules/.pnpm/@hyperswarm+secret-stream@6.1.0/node_modules/@hyperswarm/secret-stream/index.js:463:5)
    at WritableState.updateNonPrimary (/home/louneskmt/test/node_modules/.pnpm/streamx@2.12.5/node_modules/streamx/index.js:189:16)
    at WritableState.update (/home/louneskmt/test/node_modules/.pnpm/streamx@2.12.5/node_modules/streamx/index.js:174:70)
    at WritableState.afterOpen (/home/louneskmt/test/node_modules/.pnpm/streamx@2.12.5/node_modules/streamx/index.js:501:27)
    at NoiseSecretStream._predestroy (/home/louneskmt/test/node_modules/.pnpm/@hyperswarm+secret-stream@6.1.0/node_modules/@hyperswarm/secret-stream/index.js:390:7)
    at NoiseSecretStream.destroy (/home/louneskmt/test/node_modules/.pnpm/streamx@2.12.5/node_modules/streamx/index.js:572:12)
    at Holepuncher.onabort (/home/louneskmt/test/node_modules/.pnpm/@hyperswarm+dht@6.3.3/node_modules/@hyperswarm/dht/lib/connect.js:154:43)
    at Holepuncher.destroy (/home/louneskmt/test/node_modules/.pnpm/@hyperswarm+dht@6.3.3/node_modules/@hyperswarm/dht/lib/holepuncher.js:279:31)
    at Holepuncher._autoDestroy (/home/louneskmt/test/node_modules/.pnpm/@hyperswarm+dht@6.3.3/node_modules/@hyperswarm/dht/lib/holepuncher.js:267:31) {
  code: 'HOLEPUNCH_ABORTED'
}

Node.js v18.12.1

I have been able to make it work by manually setting remoteHolepunchable to false here:
https://github.com/hyperswarm/dht/blob/e2b4cb8588d1954765f176c2f092ecf72966f2d3/lib/connect.js#L139

Received new connection from 172.81.0.1
Connection from 172.81.0.1 was closed 

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions