11

I am getting too few connections (5) since about 2 Days. I think adding peers to my "config.js" file should help, but I am not sure how it should look like.

Can I simply add the IP and Port to a blank file and put it into the ./tezos-node folder? Or does the config.js have to have a specific format and contain specific (further) information?

  • The config file is config.json, please update the question to reduce confusion. – Phlogi Aug 29 at 12:49
7

Some "just started node" sometime ends up in a situation like that and work is done to get rid of the problem. The scenario is the following:

  • The bootstrap peers accept a big number of connection so there is never any problem to connect to them
  • Then, they send back always the same subset of their peers. And these peers do not accept hundred of connection so they end up being all saturate and therefore none reply.
  • The node is stuck in this stage until being given by hand via admin-client connect address [...] the address of a non saturated node that accepts the connection and gives some addresses of some other non saturated nodes and everything is finally fine.

We are working on it by making saturated nodes while refusing an extra connection sending back anyway a subset of their peers to try...

8

Is your node in private mode ? It's bizarre to only have 5 connections while there are hundreds of peers in the networks. Have you tried to restart your node ? and/or to generate a new identity ? Maybe the other nodes have blacklisted yours.

You can either add peers with command line option --peer ADDR:PORT, or by adding them in the config.json file. Via the config file, you can for instance add the peers as follows:

{
  "p2p": {
    "bootstrap-peers": ["127.0.0.1:9731"],
}
  • No private mode. And yes i've tried to restart several times. Why should somebody blacklist me? – Blindripper Feb 15 at 21:08
  • 2
    One may blacklist you if, for instance, it considers that you are not behaving like a "normal" node: (your data are not well formed, you try to flood the other node with the same request, ....). You can try to print more debug traces (with -vvv) and see why connections are refused/closed. – iguer Feb 15 at 21:30
  • Ok that can't be the case, i behave "normal" :) – Blindripper Feb 15 at 22:02
8

Ok, i've tried to open ports, generated a new identity, added peers manually (like iguer) adviced, but nothing helped.

But a guy called "Krixt" in the Tezos Baking slack wrote this script:

#!/bin/bash

# get foundation nodes
for i in dubnodes franodes sinnodes nrtnodes pdxnodes; do
    for j in `dig $i.tzbeta.net +short`; do
      echo "Connecting foundation $j..."
      ~/tezos/tezos-admin-client connect address [$j]:9732
    done
done

# public nodes
for j in 0 1; do
  for i in `curl -s "http://api6.tzscan.io/v3/network?state=running&p=$j&number=50" \
    | jq -r '.[] | .point_id' | xargs`; do

    # handle ipv4 or ipv6
    numparts=$(echo $i | awk -F: '{print NF}')
    basenum=$((numparts-1))
    port=$(echo $i | cut -d: -f$numparts)
    base=$(echo $i | cut -d: -f1-$basenum)
    formatted="[$base]:$port"

    echo "Connecting $formatted..."
    ~/tezos/tezos-admin-client connect address $formatted
  done
done

Source: https://gist.github.com/utdrmac/2125a8514960e163837e86bc934f19b6

This script is a true connection booster :) I've now more than 100 connections (from 5 before).

I hope this will help others with the same "too few connections" problems ;)

  • 1
    Nice ! Although this does not explain why the node is not discovering the network by its own. This is maybe a case that needs investigation and debug by dev team. – iguer Feb 16 at 10:11
  • Yeah, i am running since cycle 7 without problems or changes (Except the code updates). Weired. – Blindripper Feb 16 at 10:13
  • I'm glad something works for you. But again, this script makes connections to others. The problem is surely that others can't connect to you, you should dig more into it instead of using a bandaid. A normal node gets about 50+ connections on its own in its stable state, 10+ within the first few minutes. – Frank Feb 16 at 15:36
  • The problem also raised after i've created a new identity. So I think it can not have anything to do with blacklisting. And it would be strange, if all other nodes took more than 70 cycles to blacklist me. – Blindripper Feb 17 at 10:05
2

As iguer pointed out, private mode would be one reason to cause this. But to elaborate, this happens mostly because private mode nodes are less favorable for a peer node to connect to as the private node is basically a leech to the network. It will not try to bootstrap other nodes. Private nodes will mostly just monitor to get the blockchain and fill its mempool, only sometimes occasionally share an operation like baking or transaction.

Fundamentally, a private node does not allow others to connect to it. For the same reason, if your public node does not allow others to connect to it, it will share the "too few connections" symptoms. It's not a node requirement to allow others to connect because the node itself can try to connect to known peers and bootstrap the chain that way. But my theory is that nodes that does not allow connections from others are also considered less favorable, hence some nodes might drop or refuse your node as a peer because it doesn't help expand their reach to the network. I would certainly check to make sure your port 9732 is connectable through your firewall or router or whatever. (Official documentations says it's port 19732, but I believe that's wrong based on my experience.)

Third reason why too few connections may happen is rare but should be pointed out. If you are on the wrong network or fork/chain or protocol, you will only connected to compatible nodes. All the nodes you are connected will be also on the same setup. Things to watch out for is to make sure to compile your binaries with mainnet branch, not master. Also, remember to run the correct binaries (currently at 003 protocol) and keep your binaries up to date by recompiling every so often(or notified to do so on Riot or Slack).

  • 1
    The third one was valid for me :) I was running on a docker/master instead of mainnet and the node could not connect to any peer. Thank you! – mitelone Feb 20 at 13:45
0

This is the command to add a peer permanently to the config.json file in the tezos data directory:

tezos-node config update --peer=13.251.160.63:9732 --peer=...

This command does unfortunately not check for already existing entries. So you can end up adding the same peers multiple times.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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