Proxy endpoint feature unavailable

RCF support and general discussion.
Post Reply
wulixue
Posts: 8
Joined: Sun Dec 20, 2015 6:26 pm

Proxy endpoint feature unavailable

Post by wulixue »

proxy server code:

int main()
{
RCF::RcfInit rcfInit;

std::string networkInterface = "0.0.0.0";
int port = 50001;
std::cout << "Starting proxy server on " << networkInterface << ":" << port << "." << std::endl;
RCF::RcfServer server(RCF::TcpEndpoint(networkInterface, port));
server.setEnableProxyEndpoints(true);
server.start();

std::cout << "Press Enter to exit..." << std::endl;
std::cin.get();

return 0;
}

Destination Server code:

int main()
{
RCF::RcfInit rcfInit;

std::string networkInterface = "127.0.0.1";
int port = 50001;
std::cout << "Starting server on " << networkInterface << ":" << port << "." << std::endl;

// Start a TCP server, and expose MyServiceImpl.
MyServiceImpl myServiceImpl;
std::string server_name = "test_server";

////
//RCF::ProxyEndpoint proxyServerEndpoint(RCF::TcpEndpoint(networkInterface, port), server_name);
//RCF::RcfServer server(proxyServerEndpoint);

RCF::RcfServer server(RCF::ProxyEndpoint(RCF::TcpEndpoint(networkInterface, port), server_name));

server.bind<MyService>(myServiceImpl);
server.start();

std::cout << "Press Enter to exit..." << std::endl;
std::cin.get();

return 0;
}

clinet code:

int main()
{
RCF::RcfInit rcfInit;

try
{

std::string networkInterface = "127.0.0.1";
int port = 50001;
std::cout << "Connecting to server on " << networkInterface << ":" << port << "." << std::endl;

// Setup a vector of strings.
std::vector<std::string> v;
v.push_back("one");
v.push_back("two");
v.push_back("three");

// Print them out.
std::cout << "Before:\n";
std::copy(
v.begin(),
v.end(),
std::ostream_iterator<std::string>(std::cout, "\n"));



std::string server_name = "test_server";
// Make the call.
RcfClient<MyService> client(RCF::ProxyEndpoint(RCF::TcpEndpoint(networkInterface, port), server_name));
client.reverse(v);
// Print them out again. This time they are in reverse order.
std::cout << "\nAfter:\n";
std::copy(
v.begin(),
v.end(),
std::ostream_iterator<std::string>(std::cout, "\n"));
}
catch(const RCF::Exception & e)
{
std::cout << "Caught exception:\n";
std::cout << e.getErrorMessage() << std::endl;
return 1;
}

return 0;
}

As described,the destination server successfully connects to the proxy server, but client Initialize error.

ClientTransportUniquePtr RcfServer::makeProxyEndpointConnection(const std::string& proxyEndpointName)
{
if ( mProxyEndpointServicePtr ) //Note:error is here
{
return mProxyEndpointServicePtr->makeProxyEndpointConnection(proxyEndpointName);
}
return ClientTransportUniquePtr();
}

If the destination server's code is changed to the following expression, the initialization of the destination server will also fail.

//
RCF::ProxyEndpoint proxyServerEndpoint(RCF::TcpEndpoint(networkInterface, port), server_name);
RCF::RcfServer server(proxyServerEndpoint);

//RCF::RcfServer server(RCF::ProxyEndpoint(RCF::TcpEndpoint(networkInterface, port), server_name));


error:
ProxyEndpointTransport::ProxyEndpointTransport(
const Endpoint& ep,
const std::string& proxyEndpointName) :
mEndpointPtr(ep.clone()), //note:error is here
mEndpointName(proxyEndpointName)
{
}

your sample codes, proxyendpoint sample. It is very unusual for proxy servers and clients to be on the same server. So what should be the correct usage?

I'm a paying user, id: wulixue@163.com, testing features of 3.0. When I use 2.2, I also encounter a lot of problems. I would like to know if you released these features after a complete test. Otherwise, why can't the simple sample code work properly?

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

Re: Proxy endpoint feature unavailable

Post by jarl »

Hi there,

The proxy endpoint feature is new in RCF 3.0, and replaces the "callback connection" concept that existed in RCF 2.2. So code that would have used "callback connections" in RCF 2.2, should now use proxy endpoints.

As you've noticed the proxy server is currently only able to be used by RcfClient's in the same process, using code like the sample code:

// Client calling through proxy server.
RcfClient<I_PrintService> client( RCF::ProxyEndpoint(proxyServer, "RoamingPrintSvr") );
client.Print("Calling I_PrintService through a proxy endpoint");

(where proxyServer is a RcfServer object)

So I agree it's a bit of a stretch at this point to call it a proxy server. It is basically just a mechanism to provide the functionality that callback connections provided in RCF 2.2. The intention is to subsequently add more functionality to allow remote clients to use the proxy server as well.

Having said that, if this functionality (remote access to proxy endpoint) is important to you, please let me know, in which case we'll prioritize it.
Kind Regards

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

Post Reply