I am trying to run a simple RPC program which I have created using rpcgen. Its a simple factorial program. This is my first RPC program. The make works fine.Executables are also created. But when trying to run the executables, I get this error:
$sudo ./fact_server
Cannot register service: RPC: Unable to receive; errno = Connection refused
unable to register (FACTPROGRAM, FACTVERSION, udp).
I tried running the same program on another pc with the same OS (ubuntu). It runs perfect there.
First you check that portmapper is working or not, use rpcinfo
to check it.
If you get any error then install portmap
Check whether the service is running using rpcinfo
. Here's what I get.
$ rpcinfo
program version netid address service owner
100000 4 tcp6 ::.0.111 portmapper superuser
100000 3 tcp6 ::.0.111 portmapper superuser
100000 4 udp6 ::.0.111 portmapper superuser
100000 3 udp6 ::.0.111 portmapper superuser
100000 4 tcp 0.0.0.0.0.111 portmapper superuser
100000 3 tcp 0.0.0.0.0.111 portmapper superuser
100000 2 tcp 0.0.0.0.0.111 portmapper superuser
100000 4 udp 0.0.0.0.0.111 portmapper superuser
100000 3 udp 0.0.0.0.0.111 portmapper superuser
100000 2 udp 0.0.0.0.0.111 portmapper superuser
100000 4 local /run/rpcbind.sock portmapper superuser
100000 3 local /run/rpcbind.sock portmapper superuser
24 5 udp 0.0.0.0.3.99 - superuser
24 5 tcp 0.0.0.0.3.100 - superuser
If the service is not running, you have to start it with rpcbind
. On Ubuntu I needed root privileges to run the service.
There is a bug/feature in recent Linux releases of rpcbind - it is now not active/running after system boot, but should somehow be "socket activated" according to systemctl configuration rpcbind.service file in /usr/lib/systemd/system/:
[Install]
Also=rpcbind.socket
Check this thread on same bug/feature caused Ubuntu issues (https://bugs.launchpad.net/ubuntu/+source/rpcbind/+bug/1558196).
The short answer to yours (ours) issue with rpcbind is - in order to run the RPC server code, do this amendment to systemctrl configuration of your system:
sudo systemctl add-wants multi-user.target rpcbind
Now, the intended way to set rpcbind running is to somehow access /var/run/rpcbind.sock, I would owe much to some Unix/Linux guru that may enlighten me on what RPC server application code shall do in order to achieve this rpcbind "socket activation" effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With