Proxy endpoint feature unavailable
Posted: Fri Jan 04, 2019 7:07 am
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?
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?