Running Demo on separate machines: OS111 - Connection refuse

RCFProto support and general discussion.
Post Reply
HansdB
Posts: 2
Joined: Wed Jun 25, 2014 2:42 pm

Running Demo on separate machines: OS111 - Connection refuse

Post by HansdB »

I have two machines running Ubuntu. Both are in the same network and are able to ping each other.

On both machines I built the demo application and on both machines this demo app is running fine via localhost.

However, when I adapt DemoClient.cpp on one of the machines to use the IP address of the other machine instead of localhost, i.e.,

Code: Select all

endpoints.push_back( RCF::EndpointPtr( new RCF::TcpEndpoint(50001) ) );
is changed into

Code: Select all

endpoints.push_back( RCF::EndpointPtr( new RCF::TcpEndpoint("192.168.109.131", 50001) ) );
and subsequently build and run the DemoClient, this results in:

Code: Select all

RCF::Exception: Unable to establish network connection. OS: 111 - Connection refused
When running tcpdump on the server machine (sudo tcpdump -i eth0) I do observe connection attempts from the client.

Any suggestions?

jarl
Posts: 238
Joined: Mon Oct 03, 2011 4:53 am
Contact:

Re: Running Demo on separate machines: OS111 - Connection re

Post by jarl »

By default, the server is only listening on the loopback interface. In DemoServer.cpp, if you change these lines:

Code: Select all

        // Add the endpoints that this server will support.
        std::vector<RCF::EndpointPtr> endpoints;
        endpoints.push_back( RCF::EndpointPtr( new RCF::TcpEndpoint(50001) ) );
        endpoints.push_back( RCF::EndpointPtr( new RCF::HttpEndpoint(50002) ) );
, to

Code: Select all

        // Add the endpoints that this server will support.
        std::vector<RCF::EndpointPtr> endpoints;
        endpoints.push_back( RCF::EndpointPtr( new RCF::TcpEndpoint("0.0.0.0", 50001) ) );
        endpoints.push_back( RCF::EndpointPtr( new RCF::HttpEndpoint("0.0.0.0", 50002) ) );
, it will listen on all network interfaces and your client will be able to connect.
Kind Regards

Jarl Lindrud
Delta V Software
http://www.deltavsoft.com

HansdB
Posts: 2
Joined: Wed Jun 25, 2014 2:42 pm

Re: Running Demo on separate machines: OS111 - Connection re

Post by HansdB »

Thanks, that is the solution.

I suspected something like this to be necessary but was not able to find it in the documentation.

Instead of "0.0.0.0" I tried the IP address of the client and an empty string; these don't work.

I was wondering whether the IP address on the server side could be interpreted as a mask allowing me to limit access to clients in a particular subdomain.
Right now, I observe that the address must really be "0.0.0.0" or "127.0.0.1" to be able to start the server.

jarl
Posts: 238
Joined: Mon Oct 03, 2011 4:53 am
Contact:

Re: Running Demo on separate machines: OS111 - Connection re

Post by jarl »

The IP address for the server is just that of the network interface the server should listen on. You can have multiple network interfaces on a machine, with individual IP addresses, so the IP address can be used to specify a particular network interface. Alternatively you can specify "0.0.0.0" to listen on all interfaces, or "127.0.0.1" to listen only on the loopback interface.

As your server is in C++, you can configure client address filtering, as for RCF:

http://www.deltavsoft.com/doc/rcf_user_ ... fig.Access

RcfProtoServer is derived from RcfServer, so you can follow the example in the User Guide:

Code: Select all

RcfProtoServer server(...);

RCF::IpServerTransport & ipTransport = 
    dynamic_cast<RCF::IpServerTransport &>(server.getServerTransport());

std::vector<RCF::IpRule> rules;

// Match 11.22.33.* (24 significant bits).
rules.push_back( RCF::IpRule( RCF::IpAddress("11.22.33.0"), 24) );

ipTransport.setAllowIps(rules);
Kind Regards

Jarl Lindrud
Delta V Software
http://www.deltavsoft.com

Post Reply