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.
addnode
just tells your node to consider connecting to that address. It doesn't treat inbound connections specially, or connect to the address.