0

Can anyone help ? I'm stuck. I have an EC2 instance, and a client/server Sun RPC app that works fine locally.

The server part runs ok on the EC2 instance (starts, waits for client connections.

The client portion running on my home PC always says:

localhost: RPC: Remote system error - Connection refused

I have run rpcinfo -p on both client and server, they look ok to me:

EC2 server:

   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
 536871049    2   udp  36832
 536871049    2   tcp  43244

Client:

   program vers proto   port  service
    100000    4   tcp    111  portmapper
    100000    3   tcp    111  portmapper
    100000    2   tcp    111  portmapper
    100000    4   udp    111  portmapper
    100000    3   udp    111  portmapper
    100000    2   udp    111  portmapper
       199    1   udp  35634
       199    1   tcp  43545
 536871049    2   udp  52507
 536871049    2   tcp  57459
 536871048    1   udp  49297
 536871048    1   tcp  54609

I have opened up port 111 for TCP inbound on the EC2 instance. It looks open from the client: nping -p 111 ec2-XX-XXX-XX-XX.us-west-2.compute.amazonaws.com returns a response.

Anyone any ideas ?

MalcolmH
  • 33
  • 4
  • I think the error message already told you the problem : your apps try to connect to RPC hosts name `localhost`. Check your application setup. – mootmoot Apr 24 '17 at 08:53
  • The `portmapper` allocates ports to RPC services dynamically, or rather the services allocate their own ports dynamically and register them with the `portmapper`. All this was devised in the early 1980s prior to firewalls. Sun-RPC really is not suitable for this reason for deployment on the Internet 30 years later. – user207421 Apr 25 '17 at 09:28

1 Answers1

0

Ah, as mootmoot pointed out, I was running my client locally.

However, when I changed that, it still didn't work. Apart from port 111 you also have to open up the port that the service is running on. My program has a number 536871049, so I have to open port 43244 for TCP (the protocol I was using).

But, everytime you restart the service, the port number changes as the template server code calls:

transp = svctcp_create(RPC_ANYSOCK, 0, 0);

which binds the service to an arbitary port. So I had to set up my own socket against a known port and then change the call above to use that socket.

Then you can go into AWS an open the inbound connections to the EC2 server on ports 111 plus the port setup above. It all then works fine!

MalcolmH
  • 33
  • 4