Re: [libjsonrpccpp-devel] No client connection handler found
Brought to you by:
cinemast
|
From: Peter Spiess-K. <de...@sp...> - 2016-11-29 21:40:08
|
Hi Jason! Sorry for the late response, I've been busy lately. First, is there a reason why you are not using the stub-generator? It usually eliminates most manual interface errors. >From the current code snippet, I cannot see any error now, but I could overlook something. Could paste the URL to the project or something that is actually compileable? This makes debugging easier. This error comes from here: https://github.com/cinemast/libjson-rpc-cpp/blob/ccbdb41388bdd929828941652da816bf52a0580e/src/jsonrpccpp/server/connectors/httpserver.cpp#L159 This means that the RPC server is not properly registered with the server connector. Greetings, Peter On 11/23/2016 09:10 PM, Jason Miesionczek wrote: > Hello, > > trying to get a basic json-rpc server up and running. Upon testing a > method, i get this error from curl: > > No client connection handler found > > Here is my code: > > #include <jsonrpccpp/server.h> > > class AbstractStubServer : public > jsonrpc::AbstractServer<AbstractStubServer> > { > public: > AbstractStubServer(jsonrpc::AbstractServerConnector &conn, > jsonrpc::serverVersion_t type = jsonrpc::JSONRPC_SERVER_V2) : > jsonrpc::AbstractServer<AbstractStubServer>(conn, type) > { > this->bindAndAddMethod(jsonrpc::Procedure("connect", > jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, > "password",jsonrpc::JSON_STRING,"uri",jsonrpc::JSON_STRING, NULL), > &AbstractStubServer::connectI); > this->bindAndAddMethod(jsonrpc::Procedure("hostGetVersion", > jsonrpc::PARAMS_BY_NAME, jsonrpc::JSON_STRING, > "connID",jsonrpc::JSON_STRING, NULL), &AbstractStubServer::hostGetVersionI); > } > > inline virtual void connectI(const Json::Value &request, > Json::Value &response) > { > response = this->connect(request["password"].asString(), > request["uri"].asString()); > } > inline virtual void hostGetVersionI(const Json::Value &request, > Json::Value &response) > { > response = this->hostGetVersion(request["connID"].asString()); > } > virtual std::string connect(const std::string& password, const > std::string& uri) = 0; > virtual std::string hostGetVersion(const std::string& connID) = 0; > }; > > using namespace jsonrpc; > using namespace std; > > class RpcServer : public AbstractStubServer > { > public: > RpcServer(AbstractServerConnector &connector, > SHRDPTR(Drivers::DriverManager) manager); > > virtual std::string connect(const std::string &password, const > std::string &uri); > virtual std::string hostGetVersion(const std::string& connID); > > private: > std::map<std::string, SHRDPTR(Drivers::IDriver)> connectionMap_; > SHRDPTR(Drivers::DriverManager) > manager_; > }; > > RpcServer::RpcServer(AbstractServerConnector &connector, > SHRDPTR(Drivers::DriverManager) manager) : > AbstractStubServer(connector), manager_(manager) > { > > } > > std::string genConnectionID(std::string uri, std::string password) > { > unsigned char result[MD5_DIGEST_LENGTH]; > MD5((unsigned char*)uri.c_str(), uri.size(), result); > > std::ostringstream sout; > sout<<std::hex<<std::setfill('0'); > for(long long c: result) > { > sout<<std::setw(2)<<(long long)c; > } > return sout.str(); > } > > std::string RpcServer::connect(const std::string &password, const > std::string &uri) > { > auto conn = MKSHRD(Connection::HypervisorConnection, uri, password); > auto factory = this->manager_->get(conn->getProtocol()); > auto driver = factory->create(conn); > auto id = genConnectionID(uri, password); > this->connectionMap_[id] = driver; > return id; > } > > std::string RpcServer::hostGetVersion(const std::string& connID) > { > auto driver = this->connectionMap_[connID]; > return driver->hostGetVersion(); > } > > and in main: > > HttpServer httpServer(8383); > RpcServer rpcServer(httpServer, manager); > rpcServer.StartListening(); > getchar(); > rpcServer.StopListening(); > > What am I missing? > > Thanks, > Jason > > > ------------------------------------------------------------------------------ > > > > _______________________________________________ > libjsonrpccpp-devel mailing list > lib...@li... > https://lists.sourceforge.net/lists/listinfo/libjsonrpccpp-devel > |