Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error [ERR_SOCKET_DGRAM_NOT_RUNNING]: Not running #65

Closed
MichaelJCole opened this issue Apr 2, 2024 · 1 comment · Fixed by #82
Closed

Error [ERR_SOCKET_DGRAM_NOT_RUNNING]: Not running #65

MichaelJCole opened this issue Apr 2, 2024 · 1 comment · Fixed by #82

Comments

@MichaelJCole
Copy link

Hi, I'm getting this error trying to use the PMP client.

import { upnpNat, pmpNat } from '@achingbrain/nat-port-mapper'

async function main() {

//    const client = await upnpNat({
    const client = await pmpNat({
        // all fields are optional
        ttl: 20*60, // how long mappings should live for in seconds - min 20 minutes, default 2 hours
        description: 'hello', // default description to pass to the router for a mapped port
        gateway: '10.2.0.1', // override the router address, will be auto-detected if not set
        keepAlive: true // if true, refresh the mapping ten minutes before the ttl is reached, default true
    })


    
    // Map public port 1000 to private port 1000 with TCP
    await client.map({
        localPort: 1000,
        protocol: 'TCP'
    })

    // Get external IP
    const externalIp = await client.externalIp()
    
    console.log('External IP:', externalIp)
    
    // Unmap all mapped ports
    client.close()
}
main()

Here's the error:

> $ node index.mjs                                                                                                                                                ⬡ 18.18.2 
External IP: {
  msg: <Buffer 00 80 00 00 00 07 5c 98 59 2d 04 0c>,
  vers: 0,
  op: 128,
  resultCode: 0,
  resultMessage: 'Success',
  epoch: 482456,
  ip: [ 89, 45, 4, 12 ]
}
node:internal/errors:496
    ErrorCaptureStackTrace(err);
    ^

Error [ERR_SOCKET_DGRAM_NOT_RUNNING]: Not running
    at new NodeError (node:internal/errors:405:5)
    at healthCheck (node:dgram:920:11)
    at Socket.bind (node:dgram:240:3)
    at PMPClient.connect (file:///home/michael/temp/node_modules/@achingbrain/nat-port-mapper/dist/src/pmp/index.js:62:21)
    at PMPClient._next (file:///home/michael/temp/node_modules/@achingbrain/nat-port-mapper/dist/src/pmp/index.js:201:22)
    at PMPClient.request (file:///home/michael/temp/node_modules/@achingbrain/nat-port-mapper/dist/src/pmp/index.js:182:14)
    at PMPClient.map (file:///home/michael/temp/node_modules/@achingbrain/nat-port-mapper/dist/src/pmp/index.js:83:14)
    at async PMPClient.unmap (file:///home/michael/temp/node_modules/@achingbrain/nat-port-mapper/dist/src/pmp/index.js:88:9)
    at async NatAPI.unmap (file:///home/michael/temp/node_modules/@achingbrain/nat-port-mapper/dist/src/index.js:57:9) {
  code: 'ERR_SOCKET_DGRAM_NOT_RUNNING'
}

Node.js v18.18.2

It appears the client is attempting to bind to a closed socket. https://stackoverflow.com/a/56016615/1483977

@achingbrain
Copy link
Owner

Could you submit a PR with a fix? PMP seems to be broken on my router after an update, it's enabled in config but the ports are closed so I can only use UPnP at the moment.

github-actions bot pushed a commit that referenced this issue Nov 26, 2024
## [3.0.1](v3.0.0...v3.0.1) (2024-11-26)

### Bug Fixes

* close socket after pmp unmap ([#82](#82)) ([52f87ad](52f87ad)), closes [#65](#65)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants