0

I've written a simple script "node" that will connect to the local node running on my computer.

I can see that it's connected using:

$ bitcoin-cli getpeerinfo

{
    "id": 27,
    "addr": "127.0.0.1:37992",
    "addrlocal": "127.0.0.1:18333",
    "services": "0000000000000001",
    "relaytxes": true,
    "lastsend": 1479746037,
    "lastrecv": 1479746037,
    "bytessent": 325460,
    "bytesrecv": 6007,
    "conntime": 1479745618,
    "timeoffset": 0,
    "pingwait": 419.673504,
    "version": 60002,
    "subver": "",
    "inbound": true,
    "startingheight": 0,
    "banscore": 0,
    "synced_headers": -1,
    "synced_blocks": -1,
    "inflight": [
    ],
    "whitelisted": false,
    "bytessent_per_msg": {
      "block": 236393,
      "getheaders": 1053,
      "inv": 5898,
      "ping": 32,
      "tx": 81934,
      "verack": 24,
      "version": 126
    },
    "bytesrecv_per_msg": {
      "getdata": 5898,
      "version": 109
    }
  }
}

However, the script will eventually lose connection to my local node and stop receiving messages. This usually happens within a space of an hour.

  • What causes a node to drop a connection to an incoming node?
  • Is it possible to make my local node to allow a permanent incoming connection (from my local script)?

EDIT: I've tried addnode=127.0.0.1 in my bitcoin.conf, but it doesn't help with reconnecting if the connection is dropped.

3
  • 1
    addnode just tells your node to consider connecting to that address. It doesn't treat inbound connections specially, or connect to the address.
    – Nick ODell
    Commented Nov 21, 2016 at 18:50
  • 1
    Are you responding to ping requests? it may be dropping the connection because you look unresponsive. Commented Nov 21, 2016 at 18:57
  • @PieterWuille. No, I've not been responding to ping requests. Thank you.
    – inersha
    Commented Nov 21, 2016 at 20:29

1 Answer 1

1

Solution: The node has been sending my script ping messages, but my script was not responding with pong messages.

The ping message is sent primarily to confirm that the TCP/IP connection is still valid. An error in transmission is presumed to be a closed connection and the address is removed as a current peer. https://en.bitcoin.it/wiki/Protocol_documentation#ping

Therefore, my script "node" appeared to be unresponsive, so the local node would drop the connection.


Thanks to Pieter Wuille for pointing me in the right direction.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.