noia-network / noia-node-cli

NOIA node headless (terminal) sample for noia-node.
GNU Lesser General Public License v2.1
11 stars 4 forks source link

uncaughtException: Port should be > 0 and < 65536. Received 0. #10

Closed maaft closed 3 years ago

maaft commented 6 years ago

Describe the bug

error: [noia-contents-client] uncaughtException: Port should be > 0 and < 65536. Received 0. date=Wed Sep 05 2018 18:47:40 GMT+0200 (GMT+02:00), pid=15656, uid=1001, gid=1001, cwd=/home/noia/noia/noia-node-cli, execPath=/usr/bin/node, version=v10.9.0, argv=[/usr/bin/node, /home/noia/noia/noia-node-cli/dist/index.js], rss=76709888, heapTotal=38125568, heapUsed=30695424, external=16960161, loadavg=[0.0791015625, 0.03564453125, 0.0078125], uptime=4376333, trace=[column=11, file=dgram.js, function=Socket.send, line=391, method=send, native=false, column=25, file=/home/noia/noia/noia-node-cli/node_modules/@noia-network/webrtc-direct-server/dist/udp-proxy.js, function=Socket.server.on, line=96, method=on, native=false, column=13, file=events.js, function=Socket.emit, line=182, method=emit, native=false, column=8, file=dgram.js, function=UDP.onMessage [as onmessage], line=638, method=onMessage [as onmessage], native=false], stack=[RangeError [ERR_SOCKET_BAD_PORT]: Port should be > 0 and < 65536. Received 0.,     at Socket.send (dgram.js:391:11),     at Socket.server.on (/home/noia/noia/noia-node-cli/node_modules/@noia-network/webrtc-direct-server/dist/udp-proxy.js:96:25),     at Socket.emit (events.js:182:13),     at UDP.onMessage [as onmessage] (dgram.js:638:8)]

To Reproduce Steps to reproduce the behavior:

  1. Fresh Ubuntu 16.04 LTS installation
  2. installed nodejs 10.09
  3. https://github.com/noia-network/noia-node-cli/
  4. cd noia-node-cli && npm install && npm run build && npm start
  5. configure ~/.noia-node-cli/settings.json with wallet address, public IP
  6. npm start
  7. wait some minutes until the error arises

Content of settings.json

{
  "isHeadless": true,
  "skipBlockchain": true,
  "statisticsPath": "/home/noia/.noia-node-cli/statistics.json",
  "storage.dir": "/home/noia/.noia-node-cli/storage",
  "storage.size": "104857600",
  "domain": "",
  "ssl": false,
  "ssl.privateKeyPath": "",
  "ssl.crtPath": "",
  "ssl.crtBundlePath": "",
  "publicIp": "**removed**",
  "sockets.http": false,
  "sockets.http.ip": "0.0.0.0",
  "sockets.http.port": "6767",
  "sockets.ws": false,
  "sockets.ws.ip": "0.0.0.0",
  "sockets.ws.port": "7676",
  "sockets.wrtc": true,
  "sockets.wrtc.control.port": "8048",
  "sockets.wrtc.control.ip": "0.0.0.0",
  "sockets.wrtc.data.port": "8058",
  "wallet.address": "**removed**",
  "wallet.mnemonic": "**removed**",
  "masterAddress": "ws://csl-masters.noia.network:5565",
  "whitelist.masters": [],
  "controller": false,
  "controller.ip": "127.0.0.1",
  "controller.port": "9000",
  "nodeId": "**removed**",
  "sockets.wrtc.data.ip": "**removed**"
}
maaft commented 6 years ago

Update

  1. Uninstalled nodejs v10.09 & installed nodejs v8.4.11 LTS
  2. Uninstalled previous global version: $ npm uninstall @noia-network/node-cli -g
  3. Installed new version: $ npm install @noia-network/node-cli -g --unsafe-perm
  4. Started global node version: $ noia-node-cli
  5. Wait

Error

dgram.js:419
    throw new errors.RangeError('ERR_SOCKET_BAD_PORT');
    ^

RangeError [ERR_SOCKET_BAD_PORT]: Port should be > 0 and < 65536
    at Socket.send (dgram.js:419:11)
    at Socket.server.on (/usr/lib/node_modules/@noia-network/node-cli/node_modules/@noia-network/webrtc-direct-server/dist/udp-proxy.js:96:25)
    at emitTwo (events.js:126:13)
    at Socket.emit (events.js:214:7)
    at UDP.onMessage [as onmessage] (dgram.js:659:8)

Edit When testing the connection with:

const WebRtcDirect = require("@noia-network/webrtc-direct-client");
const wrtc = require("wrtc");

const address = "http://**removed**:8048";
const client = new WebRtcDirect.Client(address, {
    wrtc: wrtc
});

async function main() {
    try {
        console.log("connecting...");
        await client.connect();
        console.log("stopping...");
        await client.stop();
        console.log("exiting...");
        process.exit();
    } catch (err) {
        console.error("error", err);
    }
}

main();

the above error arises. Printing des in udp_proxy.js line 95 yields my IPv6 loopback address e.g.: ::2:40605 which results in destPort and destIP being set to 0 and therefore throwing the exception.

maaft commented 6 years ago

Quick Fix Remove IPv6 adapters with: $ sysctl -w net.ipv6.conf.all.disable_ipv6=1 $ sysctl -w net.ipv6.conf.default.disable_ipv6=1

Conclusion IPv6 support must be implemented in the future or ignore IPv6 adapters in webrtc-direct.js implementation.

maaft commented 3 years ago

Closing because this stack is deprecated.