22

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.

DannyBoi
  • 636
  • 1
  • 7
  • 23
arkiver
  • 465
  • 1
  • 5
  • 11

8 Answers8

28

First you check that portmapper is working or not, use rpcinfo to check it. If you get any error then install portmap

rekenerd
  • 462
  • 6
  • 12
7

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.

Muneeb
  • 231
  • 2
  • 4
5

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.

vleo
  • 351
  • 3
  • 4
  • I had this issue after restart and your last line helped - thanks – serup Oct 07 '16 at 07:40
  • @serup: You mean 'sudo systemctl .... ' line? Since my very last paragraph is a question, I don't know the answer to still. How to achieve that 'socket activation' - since trying to use rpc service does not do it. – vleo Jun 19 '17 at 21:53
  • yes after running last line and restart of system, then issues where gone – serup Jun 20 '17 at 06:47
2

The problem arises due to unavailability of utility like portmap or rpcbind. Install either of them to solve the problem.

pevik
  • 4,523
  • 3
  • 33
  • 44
pritam
  • 2,452
  • 1
  • 21
  • 31
2

How to install rpcgen

Type this command on the terminal.

sudo apt-get install rpcbind

but at sometimes the above code won't help you to install rpcgen.

enter image description here

At that time you have to follow these steps.Then you can easily install it. you should follow this step by step

sudo apt-get update  
sudo apt-get install rpcbind

Finally you can check it by using this command rpcinfo

enter image description here

pevik
  • 4,523
  • 3
  • 33
  • 44
1

Just install the following and try.

sudo apt install libc-dev-bin

For more information check the following GitHub. https://github.com/riyazathali/RPC-HelloWorld

Ali
  • 73
  • 5
  • 1
    Welcome ot stackoverflow! Are you sure this will help? It seems the person already marked another answer as accepted about 8 years ago. – Hami Mar 08 '20 at 11:31
  • Yeah. sure. Because, this way will deviate without relying on rpcbind. You can easily try out this by stopping the rcpbind or uninstalling the rcpbind – Ali Mar 08 '20 at 14:24
  • Okay, I have no experience at all, just wanted to to have a bit more information on your answer :) Thanks! – Hami Mar 09 '20 at 17:17
  • Check this GitHub https://github.com/riyazathali/RPC-HelloWorld – Ali Apr 12 '20 at 18:33
0

I had error using rpcinfo as well. Finally I had to run:

/etc/init.d/rpcbind start

as suggested in here.

After getting:

[info] Already running: rcpbind.

rpc server binary was able to register.

Nae
  • 14,209
  • 7
  • 52
  • 79
0

undefined reference to `xdr_wrapstring'

I think their is an issue on RCPBIND in latest ubuntu version? 22.04

jerson
  • 11
  • 2
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://stackoverflow.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://stackoverflow.com/help/whats-reputation), you can also [add a bounty](https://stackoverflow.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/33617519) – rtoijala Jan 16 '23 at 14:17