Metrics port vs node port

Is it possible to start a node with the same node port and metrics port? If not, why not?

Dunno but I bet if you read/search this, you will have a better clue

Seriously, this looks like excellent readable documentation.

Say thank you to @Traktion :thankyou:
No idea how accurate it is or consistent but it reads well so far.

and heres the same for the node

Everybody needs to read both docs to ensure its correct and consistent
and to find how this whole thing works in a very readable manner.

Well done @Traktion :clap:

3 Likes

That’ll be handy indeed. Did @Traktion create code2tutorial.com or?

I’ll be checking it out once light client networking lands.

I can only take credit for entering a URL and pressing go! :sweat_smile:

Someone did the same for AntTP and shared the link a few weeks back and I was amazed by the results!

Not sure why I didn’t try it on the autonomi repo sooner. The client one is excellent and seems factually correct too (at least I didn’t spot anything off).

The node docs I’ve only half read and I don’t have as much context, but they read well too. I don’t doubt that it will be largely correct too.

Amazing tool!

2 Likes

Stop interrupting me, I’m reading!!

Check it out now

Don’t think so, he’d have told us :slight_smile:
It looks like an excellent tool though.

just build from rc-2025.6.1
why wait?

No

The reason is the (network) operating system and the way the code is structured. It makes no logical sense to have the node port (listening port) to also be shovelling out metrics to the world, if requested.

Also they use different protocols and make protocol handling more complex.

Tl;Dr

The OS is the issue and the basic structure of the port in networking

2 Likes

Doesn’t seem to be what happens though? Metrics server binds to 127.0.0.1. Node binds to public IP. Where are you seeing the breakdown?

1 Like

That is just loopback IP address not port# It isn’t binding to this, it is binding to your network and the ipaddresses are 127.0.0.1 and the network address of your PC

If you opened in the firewall the metrics port and did port forwarding then the metrics is available from the internet. If you mangled the code to have the listening port try and decode a http request on the listening port along with the libp2p messages coming in then the world by default has access to your metrics port

1 Like

Metrics server binds to 127.0.0.1 + the port, and node binds to public IP + the port. Same port number being used by both the metrics server and the node, and it works because they’re binding to 2 different addresses. Are you saying it shouldn’t work?

I didn’t change any code it’s whatever antnode antup downloads.

Its not actually binding to those IP addresses but the network connection.

The network connection has at least 2 ip addresses

  • 127.0.0.1 loopback, basically a fudge built in from the early days when they found out they needed it
  • your PC IP address EG 192.168.1.2

Your network port can actually be setup with more Ip addresses but lets not muddy the waters.

Then your router has a WAN connection and a local network connection.

Port forwarding takes an WAN ip incoming port# and directly connects it to a PC’s network connection. EG 1.2.3.4:1234 ↔ 192.168.1.2:5678

For Nodes the WAN port number is the same as the PC port number which is the same as the listening port of the node. It could be done for the metrics port as well

The PC will direct packets in its network stack according to the port number used and ensure the IP address is one of its own. Yes it is possible for an program to restrict which IP address and/or network connection it will respond to. The node only has the option to restrict the network connection it will respond to. Loopback is a fudge will go over all.

If you use your computer’s IP address then you should be able to get metrics to respond on the metrics port. If you open your PC’s firewall for the metrics port then another computer on your LAN will be able to see the metrics using the PC’s LAN address:metrics port

What’s the issue that’s being solved here?

I suspect the question is not the right one… Not sure what’s the goal here at all…

To simplify how I run nodes by having the metrics port match the node port.

Hmm - okay - it doesn’t simplify it :wink:

You could put a reverse proxy running on one port in front of the nodes and switch between node port or metrics port depending on the target ip/source ip… But I don’t think this makes it better than it is now… It probably would be one reverse proxy per node..

we who activate metrics ports with intention usually set a range for metrics (say 15000-) and a range for nodes (say 55000-) and use them in lock step, so 15001/55001 etc.

as was said, node port runs QUIC protocol and isn’t readable by a browser. metrics port runs HTTP and uses a browser or terminal to access.

you can’t get around two ports (three really, since we also had the rpc port while that still exists)for these services, you can only not enable metrics if you’re trying to use thousands of nodes on one machine. but then you’d not be able to monitor your nodes other than logs, which large installations often disable for io reasons.

Node uses UDP, metrics uses TCP so it should work (firewall rules make the distinction between UDP and TCP, so if you open your UDP node port to the world, it doesn’t mean your TCP port will be open).