C++ framework for json-rpc (json remote procedure call)

I am currently working on a new C++17 implementation -> json-rpc-cxx.

Master Build Status codecov Develop Build Status codecov | Coverity Status

libjson-rpc-cpp

This framework provides cross platform JSON-RPC (remote procedure call) support for C++. It is fully JSON-RPC 2.0 & 1.0 compatible.

libjson-rpc-cpp logo

5 good reasons for using libjson-rpc-cpp in your next RPC project

  • Full JSON-RPC 2.0 & partial JSON-RPC 1.0 client and server Support.
  • jsonrpcstub - a tool that generates stub-classes for your JSON-RPC client and server applications.
  • Ready to use HTTP + TCP server and client to provide simple interfaces for your JSON-RPC application.
  • Cross platform build support for Linux and OS X.
  • Super liberal MIT-License.

Other good reasons to use libjson-rpc-cpp

  • Easy to use cmake cross platform build system.
  • Clean and simple architecture, which makes it easy to extend.
  • Continuously tested under MacOS, and various linux distributions.
  • Automated testing using make test.
  • Useful Examples provided. e.g. XBMC Remote using json-rpc client part and stub generator.
  • The stubgenerator currently supports C++, JavaScript, and Python.

Overview

libjson-rpc-cpp logo

Install the framework

Debian (stretch) and Ubuntu (15.10 or later)

sudo apt-get install libjsonrpccpp-dev libjsonrpccpp-tools

Fedora

sudo dnf install libjson-rpc-cpp-devel libjson-rpc-cpp-tools

Arch Linux

For Arch Linux there is a PKGBUILD provided in the AUR.

sudo aura -A libjson-rpc-cpp

Gentoo Linux

sudo emerge dev-cpp/libjson-rpc-cpp

Mac OS X

For OS X a Brew package is available:

brew install libjson-rpc-cpp

Windows

There is a ready to use compiled package here. Just download execute the installer EXE.

Build from source

Install the dependencies

UNIX

For Debian and Arch GNU/Linux based systems, all dependencies are available via the package manager. For OS X all dependencies are available in Brew

Build

git clone git://github.com/cinemast/libjson-rpc-cpp.git
mkdir -p libjson-rpc-cpp/build
cd libjson-rpc-cpp/build
cmake .. && make
sudo make install
sudo ldconfig          #only required for linux

That's it!

If you are not happy with it, simply uninstall it from your system using (inside the build the directory):

sudo make uninstall

Build options:

Default configuration should be fine for most systems, but here are available compilation flags:

  • -DCOMPILE_TESTS=NO disables unit test suite.
  • -DCOMPILE_STUBGEN=NO disables building the stubgenerator.
  • -DCOMPILE_EXAMPLES=NO disables examples.
  • -DHTTP_SERVER=NO disable the libmicrohttpd webserver.
  • -DHTTP_CLIENT=NO disable the curl client.
  • -DREDIS_SERVER=NO disable the redis server connector.
  • -DREDIS_CLIENT=NO disable the redis client connector.
  • -DUNIX_DOMAIN_SOCKET_SERVER=YES enable the unix domain socket server connector.
  • -DUNIX_DOMAIN_SOCKET_CLIENT=YES enable the unix domain socket client connector.
  • -DFILE_DESCRIPTOR_SERVER=NO disable the file descriptor server connector.
  • -DFILE_DESCRIPTOR_CLIENT=NO disable the file descriptor client connector.
  • -DTCP_SOCKET_SERVER=NO disable the tcp socket server connector.
  • -DTCP_SOCKET_CLIENT=NO disable the tcp socket client connector.

Using the framework

This example will show the most simple way to create a rpc server and client. If you only need the server, ignore step 4. If you only need the client, ignore step 3. You can find all resources of this sample in the src/examples directory of this repository.

Step 1: Writing the specification file

[
	{
		"name": "sayHello",
		"params": {
			"name": "Peter"
		},
		"returns" : "Hello Peter"
	},
	{
		"name" : "notifyServer"
	}
]

The type of a return value or parameter is defined by the literal assigned to it. The generated stubs will will use the "returns" type to validate the response. In this example you can see how to specify methods and notifications.

Step 2: Generate the stubs for client and server

Call jsonrpcstub:

jsonrpcstub spec.json --cpp-server=AbstractStubServer --cpp-client=StubClient
mkdir -p gen
mv abstractstubserver.h gen
mv stubclient.ch gen

This generates an AbstractStubServer and a StubClient class and moves them to the gen folder.

Step 3: implement the abstract server stub

Extend the abstract server stub and implement all pure virtual (abstract) methods defined in spec.json.

See src/examples/stubserver.cpp

In the main function the concrete server is instantiated and started. That is all for the server. Any JSON-RPC 2.0 compliant client can now connect to your server.

Compile the server with:

g++ stubserver.cpp -ljsoncpp -lmicrohttpd -ljsonrpccpp-common -ljsonrpccpp-server -o sampleserver

Step 4: Create the client application

See src/examples/stubclient.cpp

Compile the client with:

g++ stubclient.cpp -ljsoncpp -lcurl -ljsonrpccpp-common -ljsonrpccpp-client -o sampleclient

Contributions

Please take a look at CONTRIBUTING.md

You can also donate via Donate

Changelogs

Changelogs can be found here.

API compatibility

We do our best to keep the API/ABI stable, to prevent problems when updating this framework. A compatiblity report can be found here.

License

This framework is licensed under MIT. All of this libraries dependencies are licensed under MIT compatible licenses.

References

If you use this library and find it useful, I would be very pleased if you let me know about it.

Comments
  • Connect to flask-jsonrpc

    Connect to flask-jsonrpc

    Hi,

    we are trying to build a simple chat service (https://github.com/ne0h/catmail) that uses json rpc. While the client is implemented in c++, the server uses python with flask-jsonrpc.

    When we try to send a simple query to the server we get this error: libc++abi.dylib: terminating with unexpected exception of type Json::LogicError: Value is not convertible to Int.

    You are free to access our test service at http://miauuu.de:5000 and try the query by yourself.

    Thanks in advance, Max

  • error while trying to build on windows

    error while trying to build on windows

    64bit machine running windows 64-bit with 32-bit cygwin trying to build form source but get a dll error

    I hope that this is the correct place to report errors.

    $ make Scanning dependencies of target jsonrpccommon [ 1%] Building CXX object src/jsonrpccpp/CMakeFiles/jsonrpccommon.dir/common/errors.cpp.o [ 3%] Building CXX object src/jsonrpccpp/CMakeFiles/jsonrpccommon.dir/common/exception.cpp.o [ 4%] Building CXX object src/jsonrpccpp/CMakeFiles/jsonrpccommon.dir/common/procedure.cpp.o [ 6%] Building CXX object src/jsonrpccpp/CMakeFiles/jsonrpccommon.dir/common/specificationparser.cpp.o [ 7%] Building CXX object src/jsonrpccpp/CMakeFiles/jsonrpccommon.dir/common/specificationwriter.cpp.o [ 9%] Linking CXX shared library ../../bin/cygjsonrpccpp-common-0.dll [ 9%] Built target jsonrpccommon Scanning dependencies of target jsonrpcclient [ 10%] Building CXX object src/jsonrpccpp/CMakeFiles/jsonrpcclient.dir/client/batchcall.cpp.o [ 12%] Building CXX object src/jsonrpccpp/CMakeFiles/jsonrpcclient.dir/client/batchresponse.cpp.o [ 13%] Building CXX object src/jsonrpccpp/CMakeFiles/jsonrpcclient.dir/client/client.cpp.o [ 15%] Building CXX object src/jsonrpccpp/CMakeFiles/jsonrpcclient.dir/client/rpcprotocolclient.cpp.o [ 16%] Building CXX object src/jsonrpccpp/CMakeFiles/jsonrpcclient.dir/client/connectors/httpclient.cpp.o [ 18%] Linking CXX shared library ../../bin/cygjsonrpccpp-client-0.dll /usr/local/lib/libjsoncpp.a(json_writer.cpp.o):json_writer.cpp:(.text+0x4d0): multiple definition of Json::Writer::~Writer()' ../../lib/libjsonrpccpp-common.dll.a(d001165.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_writer.cpp.o):json_writer.cpp:(.text+0x4f0): multiple definition ofJson::FastWriter::FastWriter()' ../../lib/libjsonrpccpp-common.dll.a(d000915.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_writer.cpp.o):json_writer.cpp:(.text+0x540): multiple definition of Json::StyledWriter::StyledWriter()' ../../lib/libjsonrpccpp-common.dll.a(d000959.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_writer.cpp.o):json_writer.cpp:(.text+0x2eb0): multiple definition ofJson::FastWriter::write(Json::Value const&)' ../../lib/libjsonrpccpp-common.dll.a(d000914.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_writer.cpp.o):json_writer.cpp:(.text+0x62a0): multiple definition of Json::StyledWriter::write(Json::Value const&)' ../../lib/libjsonrpccpp-common.dll.a(d000955.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0xf50): multiple definition ofJson::Value::Value(Json::ValueType)' ../../lib/libjsonrpccpp-common.dll.a(d001094.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0xff0): multiple definition of Json::Value::Value(int)' ../../lib/libjsonrpccpp-common.dll.a(d001102.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x10e0): multiple definition ofJson::Value::Value(char const_)' ../../lib/libjsonrpccpp-common.dll.a(d001095.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x1370): multiple definition of Json::Value::Value(std::string const&)' ../../lib/libjsonrpccpp-common.dll.a(d001099.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x1520): multiple definition ofJson::Value::operator=(Json::Value)' ../../lib/libjsonrpccpp-common.dll.a(d001120.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x2fe0): multiple definition of Json::Value::operator!=(Json::Value const&) const' ../../lib/libjsonrpccpp-common.dll.a(d001418.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x3210): multiple definition ofJson::Value::size() const' ../../lib/libjsonrpccpp-common.dll.a(d001374.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x3900): multiple definition of Json::Value::operator[](std::string const&) const' ../../lib/libjsonrpccpp-common.dll.a(d001413.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x3b70): multiple definition ofJson::Value::isMember(char const_) const' ../../lib/libjsonrpccpp-common.dll.a(d001400.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x3ba0): multiple definition of Json::Value::isMember(std::string const&) const' ../../lib/libjsonrpccpp-common.dll.a(d001402.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x3bd0): multiple definition ofJson::Value::isNull() const' ../../lib/libjsonrpccpp-common.dll.a(d001383.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x3bf0): multiple definition of Json::Value::isInt() const' ../../lib/libjsonrpccpp-common.dll.a(d001379.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x40b0): multiple definition ofJson::Value::isString() const' ../../lib/libjsonrpccpp-common.dll.a(d001404.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x40c0): multiple definition of Json::Value::isArray() const' ../../lib/libjsonrpccpp-common.dll.a(d001388.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x40d0): multiple definition ofJson::Value::isObject() const' ../../lib/libjsonrpccpp-common.dll.a(d001403.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x4700): multiple definition of Json::Value::toStyledString() const' ../../lib/libjsonrpccpp-common.dll.a(d001366.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x6320): multiple definition ofJson::Value::asInt() const' ../../lib/libjsonrpccpp-common.dll.a(d001376.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x6ef0): multiple definition of Json::Value::asString() const' ../../lib/libjsonrpccpp-common.dll.a(d001397.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x7780): multiple definition ofJson::Value::~Value()' ../../lib/libjsonrpccpp-common.dll.a(d001118.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x7ad0): multiple definition of Json::Value::Value(Json::Value const&)' ../../lib/libjsonrpccpp-common.dll.a(d001098.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0x9ed0): multiple definition ofJson::Value::operator[](unsigned int)' ../../lib/libjsonrpccpp-common.dll.a(d001125.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0xa950): multiple definition of Json::Value::append(Json::Value const&)' ../../lib/libjsonrpccpp-common.dll.a(d001074.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0xb970): multiple definition ofJson::Value::operator[](char const*)' ../../lib/libjsonrpccpp-common.dll.a(d001121.o):(.text+0x0): first defined here /usr/local/lib/libjsoncpp.a(json_value.cpp.o):json_value.cpp:(.text+0xb9a0): multiple definition of `Json::Value::operator[](std::string const&)' ../../lib/libjsonrpccpp-common.dll.a(d001123.o):(.text+0x0): first defined here collect2: error: ld returned 1 exit status src/jsonrpccpp/CMakeFiles/jsonrpcclient.dir/build.make:201: recipe for target 'bin/cygjsonrpccpp-client-0.dll' failed make[2]: *** [bin/cygjsonrpccpp-client-0.dll] Error 1 CMakeFiles/Makefile2:153: recipe for target 'src/jsonrpccpp/CMakeFiles/jsonrpcclient.dir/all' failed make[1]: *** [src/jsonrpccpp/CMakeFiles/jsonrpcclient.dir/all] Error 2 Makefile:160: recipe for target 'all' failed make: *** [all] Error 2

  • Websocket implementation

    Websocket implementation

    ...where both the client and the server talk to one another without reopening a socket per RPC. I couldn't figure this out in 0.2. If it can't yet be done in another way, I'd lobby for supporting WebSockets with the following test case:

    https://github.com/Textalk/jquery.jsonrpcclient.js

    WebSockets would be excellent because you could authenticate and connect once (both expensive operations) and chat more cheaply thereafter.

    BTW, 0.2 works delightfully with a server I made with http://www.gorillatoolkit.org/pkg/rpc/v2 and http://www.gorillatoolkit.org/pkg/rpc/v2/json as long as:

    1. You name the method YourGoStruct.YourExportedMethod in the .json schema file.
    2. You call client->YourGoStruct_YourExportedMethod(...).
    3. You carefully read the generated header to see that the arguments are lexicographically sorted. :-)

    Thanks for the great library!

    Jeremy

  • How can I use this library with Visual Studio 2010?

    How can I use this library with Visual Studio 2010?

    As in the title, I would like to build the library with Visual Studio 2010, preferably statically. I found the dependencies zip, but I don't know where to place it so that cmake will find them.

  • cmake refactor

    cmake refactor

    this pull request is enhancement of #87

    if fixes the following
    • building unit_testsuite in msvc
    • building in Debug mode in msvc
    • building dynamic libraries in Xcode generated project on macos
    • fixes MACOSX_RPATH policy warning on macos
    • include_directories are not included globally any more
    • unifies CMake files style
      • use 4 spaces width tabs
      • variables use upper case
      • macros/functions use lower case
    • separated parts of cmake logic
      • separated CMakeCompilerSettings.cmake
      • separated CMakeDependencies.cmake
    • refactored FindXXX.cmake files
      • as far as i know, we do now have to add paths usr/include && usr/local/include, they should be searched by default
      • ${CMAKE_SOURCE_DIR}/win32-deps/ moved to CMAKE_PREFIX_PATH, so new cmake search paths are backwards compatible
      • FindJsoncpp.cmake don't generate any files. Instead it's using PATH_SUFFIXES to solve jsoncpp versions incompatibility.
    changes:
    • src/jsonrpccpp/CMakeLists.txt now installs all header files, if it is unwanted, we can remove them from the list by using list REMOVE_ITEM. I think it's much cleaner solution, than previous one.

    Architecture of the library itself remained unchanged, i didn't want to create any incomatibilities with previous version

  • Project cannot be easy integrate with existing CMake projects as submodule

    Project cannot be easy integrate with existing CMake projects as submodule

    When copy/clone libjson-rpc-cpp project as subdirectory/submodule to existing CMake project and add add_subdirectory(libjson-rpc-cpp) in CMakeLists.txt file, there many errors generate by CMake.

    The reason is using too much CMAKE_SOURCE_* variables. Top CMakeLists.txt file should resolve this using CMAKE_CURRENT_* variable to set proper paths to all configuration files locate below.

    Quick fix: set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

  • httpserver.cpp:58:25: error: ‘MHD_USE_EPOLL_INTERNALLY’ was not declared in this scope

    httpserver.cpp:58:25: error: ‘MHD_USE_EPOLL_INTERNALLY’ was not declared in this scope

    git clone git://github.com/cinemast/libjson-rpc-cpp.git
    mkdir -p libjson-rpc-cpp/build
    cd libjson-rpc-cpp/build
    cmake ..
    

    results in

    
    [ 24%] Building CXX object src/jsonrpccpp/CMakeFiles/jsonrpcserver.dir/server/rpcprotocolserverv1.cpp.o
    [ 25%] Building CXX object src/jsonrpccpp/CMakeFiles/jsonrpcserver.dir/server/connectors/httpserver.cpp.o
    /home/akrueger/Documents/Code/eth/libjson-rpc-cpp/src/jsonrpccpp/server/connectors/httpserver.cpp: In member function ‘virtual bool jsonrpc::HttpServer::StartListening()’:
    /home/akrueger/Documents/Code/eth/libjson-rpc-cpp/src/jsonrpccpp/server/connectors/httpserver.cpp:58:25: error: ‘MHD_USE_EPOLL_INTERNALLY’ was not declared in this scope
                 mhd_flags = MHD_USE_EPOLL_INTERNALLY;
                             ^
    src/jsonrpccpp/CMakeFiles/jsonrpcserver.dir/build.make:206: recipe for target 'src/jsonrpccpp/CMakeFiles/jsonrpcserver.dir/server/connectors/httpserver.cpp.o' failed
    make[2]: *** [src/jsonrpccpp/CMakeFiles/jsonrpcserver.dir/server/connectors/httpserver.cpp.o] Error 1
    CMakeFiles/Makefile2:176: recipe for target 'src/jsonrpccpp/CMakeFiles/jsonrpcserver.dir/all' failed
    make[1]: *** [src/jsonrpccpp/CMakeFiles/jsonrpcserver.dir/all] Error 2
    Makefile:160: recipe for target 'all' failed
    make: *** [all] Error 2
    

    on Debian 8.6

  • Please use poll or epoll(if possible) by default.

    Please use poll or epoll(if possible) by default.

    "select" has a critical issue with FD_SETSIZE. When the lowest available fd number is larger than FD_SETSIZE, server refuses to serve anything with select.

  • Brew package breaks

    Brew package breaks

    Hi!

    I'm trying to install libjson-rpc-cpp on my El Capitan OS X. I'm getting the following error:

    ==> cmake . -DCMAKE_C_FLAGS_RELEASE= -DCMAKE_CXX_FLAGS_RELEASE= -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/libjson-rpc-cpp/0.5.0 -DCMAKE_BUILD_TYPE=Rele
    ==> make
             ^
    1 error generated.
    make[2]: *** [src/jsonrpccpp/CMakeFiles/jsonrpccommon.dir/common/exception.cpp.o] Error 1
    make[1]: *** [src/jsonrpccpp/CMakeFiles/jsonrpccommon.dir/all] Error 2
    make: *** [all] Error 2
    

    Anyone has an idea of how to solve this?

    thks!

  • Ubuntu

    Ubuntu "undefined reference" after update from 0.5.0 to 0.6.0

    I use Clion on Ubuntu. Yesterday I update libjsonrpccpp-dev and libjsonrpccpp-tools from 0.5.0 to 0.6.0. After build my test project I get exception: undefined reference tojsonrpc::HttpClient::HttpClient(std::string const&)'`. Before update my test project work and i can link libraries.

    At all I install libjsonrpccpp-dev, libjsonrpccpp-tools, libjsoncpp-dev, libcurl and something else.

    main.cpp :

    #include <iostream>
    #include <wchar.h>
    #include <string>
    #include <stdlib.h>
    #include "stdio.h"
    #include <jsonrpccpp/client.h>
    #include <jsonrpccpp/client/connectors/httpclient.h>
    using namespace jsonrpc;
    using namespace Json;
    using namespace std;
    int main() {
        HttpClient httpClient("http://localhost:3333/");
        Client clientNew(httpClient);
    }
    

    Cmakelists:

    cmake_minimum_required(VERSION 3.2)
    project(testHttp)
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 ")
    set(INCLUDE_DIRECTORIES "/usr/include" "/usr/include/jsonrpccpp" "/usr/include/jsoncpp" "/usr/include/curl")
    include_directories("${INCLUDE_DIRECTORIES}" )
    set( REQUIRED_LIBRARIES jsonrpccpp-client jsonrpccpp-common jsonrpccpp-server jsoncpp curl)
    link_directories( "/usr/lib/x86_64-linux-gnu" )
    set(SOURCE_FILES main.cpp)
    add_executable(testHttp ${SOURCE_FILES})
    target_link_libraries (testHttp "${REQUIRED_LIBRARIES}")
    

    What i can do with this? :( May be i will download 0.5.0 release and build this, but i hope you help me with 0.6.0 version.

    P.S. Sorry for my english. I am from Russia :)

  • Could NOT find Git (missing:  GIT_EXECUTABLE)

    Could NOT find Git (missing: GIT_EXECUTABLE)

    Hello When I try cross compile the libjson-rpc with yocto the below message displayed: Could NOT find Git (missing: GIT_EXECUTABLE)

    Could you please tell me how to desactivate or to add the GIT recipe thanks in advance

  • Compatibility with catch-3

    Compatibility with catch-3

    Catch-3 has been released and it is somewhat compatible with Catch2 but it seems to have some changes nevertheless. Notably, catch2/catch.hpp seems to have been removed:

    /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ -DHTTP_TESTING -DSTUBGEN_TESTING -DTCPSOCKET_TESTING -DUNIXDOMAINSOCKET_TESTING -I/usr/include/jsoncpp -I/tmp/portage/dev-cpp/libjson-rpc-cpp-1.4.0/work/libjson-rpc-cpp-1.4.0_build/gen -I/tmp/portage/dev-cpp/libjson-rpc-cpp-1.4.0/work/libjson-rpc-cpp-1.4.0_build/gen/jsonrpccpp/common -I/tmp/portage/dev-cpp/libjson-rpc-cpp-1.4.0/work/libjson-rpc-cpp-1.4.0/src/test/.. -I/tmp/portage/dev-cpp/libjson-rpc-cpp-1.4.0/work/libjson-rpc-cpp-1.4.0_build  -march=znver2 --param=l1-cache-size=32 --param=l1-cache-line-size=64 -O2 -pipe -frecord-gcc-switches -std=c++11 -MD -MT src/test/CMakeFiles/unit_testsuite.dir/main.cpp.o -MF src/test/CMakeFiles/unit_testsuite.dir/main.cpp.o.d -o src/test/CMakeFiles/unit_testsuite.dir/main.cpp.o -c /tmp/portage/dev-cpp/libjson-rpc-cpp-1.4.0/work/libjson-rpc-cpp-1.4.0/src/test/main.cpp
    /tmp/portage/dev-cpp/libjson-rpc-cpp-1.4.0/work/libjson-rpc-cpp-1.4.0/src/test/main.cpp:11:10: fatal error: catch2/catch.hpp: No such file or directory
       11 | #include <catch2/catch.hpp>
          |          ^~~~~~~~~~~~~~~~~~
    compilation terminated.
    
  • Potential race condition on socket open/send (discovered on M1)

    Potential race condition on socket open/send (discovered on M1)

    Hello,

    I am finding that I have the following race condition:

    in server/connectors/unixdomainsocketserver.cpp we have:

    bool UnixDomainSocketServer::InitializeListener() {
    ...
      // Set to non-blocking mode
      fcntl(this->socket_fd, F_SETFL, FNDELAY);
    

    So a non blocking socket is created.

    Later, a connection is opened when I send data to it, and this function is called:

    void UnixDomainSocketServer::HandleConnection(int connection) {
      string request, response;
      StreamReader reader(DEFAULT_BUFFER_SIZE);
      reader.Read(request, connection, DEFAULT_DELIMITER_CHAR);
    ...
      close(connection);
    

    The read is as following:

    bool StreamReader::Read(std::string &target, int fd, char delimiter) {
      ssize_t bytesRead;
      do {
        bytesRead = read(fd, this->buffer, buffersize);
        if (bytesRead < 0) {
          return false;
        } else {
          target.append(buffer, static_cast<size_t>(bytesRead));
        }
      } while (memchr(buffer, delimiter, bytesRead) ==
               NULL); //(target.find(delimiter) == string::npos && bytesRead > 0);
    
      target.pop_back();
      return true;
    }
    

    So what happens is that if the HandleConnection call is executed fast enough, the client has not yet sent any data. Since the socket is non-blocking, the streamreader read returns -1, and the request string will be an empty string. The method then closes the connection, causing an error for the client who is trying to send data.

    The current best solution I have to this is to increase the timeout in the handler dispatch. However, it would be better I think if either the socket was blocking, or the return value from the stream reader was utilized in order to detect this case.

  • is it possible to use two or more .h stubs for one single HTTP server?

    is it possible to use two or more .h stubs for one single HTTP server?

    I have a collection of several JSON-RPC .json files which I would like to support in a single HTTP server. I have tried:

    • Reutilizing the same HttpServer object for several different stub AbstractServer child object constructors
    • Creating a child class inheriting all AbstractServer classes from my stubs which implement all their methods

    For both cases, it seems that only the last AbstractServer stub, which I include my HttpServer object in, is taken into account. Calling methods from other stubs returns a METHOD_NOT_FOUND to the calling client.

    Therefore I wanted to ask: is using several json-rpc stubs for a single httpServer (or any other AbstractServerConnector) a supported usecase of this library? If yes, any suggestions on how to implement it?

    Thanks a lot!

  • Persistent TCP connection

    Persistent TCP connection

    Hi,

    Currently in the class LinuxTcpSocketServer when a request is processed by the server in HandleConnection() the TCP connection for the client is closed after sending the response.

    Is it possible to integrate the possibility to keep the connection active so that a client can send multiple request and receive notifications without disconnecting/reconnecting

    Thanks

  • Trouble importing libjson-rpc-cpp with CMake

    Trouble importing libjson-rpc-cpp with CMake

    I have been playing around a little with libjson-rpc-cpp, and I have a question about using the CMake config files which are provided.

    Using the example on the homepage, I can manually compile and run it. I can also copy the FindMHD.cmake, FindJsonCpp.cmake files from the repo, hack together my own FindJsonRpcCpp.cmake based on them, and get a compile.

    I then noticed the CMake config files installed in /install/path/lib-json-rpc-cpp-1.3.0/lib64/libjson-rpc-cpp/cmake/ and I'm trying to figure out how to use them (since that seems preferable to hacking together my own).

    With an appropriate CMAKE_PREFIX_PATH, I can have:

    find_package(libjson-rpc-cpp CONFIG REQUIRED)
    
    add_executable(SampleClient simpleclient.cpp)
    target_link_libraries(SampleClient PUBLIC libjson-rpc-cpp::client)
    

    and have CMake run quite happily. However, the compile fails, and on closer examination, none of the required -I options are being passed. I thought those were supposed to be added automatically by the target_link_libraries() command?

  • why not support adding optional parameters to the server method

    why not support adding optional parameters to the server method

    why not support adding optional parameters to the server method? such as: virtual Json::Value GetInfo() = 0; virtual Json::Value GetInfo(const std::string &param1 ) = 0; virtual Json::Value GetInfo(const std::string &param1, const std::string &param1) = 0;

Packio - An asynchronous msgpack-RPC and JSON-RPC library built on top of Boost.Asio.

Header-only | JSON-RPC | msgpack-RPC | asio | coroutines This library requires C++17 and is designed as an extension to boost.asio. It will let you bu

Dec 26, 2022
RPC++ is a tool for Discord RPC (Rich Presence) to let your friends know about your Linux system
RPC++ is a tool for Discord RPC (Rich Presence) to let your friends know about your Linux system

RPC++ RPC++ is a tool for Discord RPC (Rich Presence) to let your friends know about your Linux system Installing requirements Arch based systems pacm

Jul 6, 2022
Linux Terminal Service Manager (LTSM) is a set of service programs that allows remote computers to connect to a Linux operating system computer using a remote terminal session (over VNC or RDP)
Linux Terminal Service Manager (LTSM) is a set of service programs that allows remote computers to connect to a Linux operating system computer using a remote terminal session (over VNC or RDP)

Linux Terminal Service Manager (LTSM) is a set of service programs that allows remote computers to connect to a Linux operating system computer using a remote terminal session (over VNC)

Dec 16, 2022
modern C++(C++11), simple, easy to use rpc framework

modern C++(C++11), simple, easy to use rpc framework

Jan 4, 2023
gRPC - An RPC library and framework Baind Unity 3D Project

Unity 3D Compose for Desktop and Android, a modern UI framework for C ++ , C# that makes building performant and beautiful user interfaces easy and enjoyable.

May 19, 2022
Nagios Plugin to check Call Quality in SIP VoIP (compatible checkmk, etc)

sipnagios Nagios Plugin to check Call Quality in SIP VoIP (compatible with check_mk, Zabbix, etc) sipnagios implements the Nagios plugin API for monit

Dec 17, 2022
Dec 15, 2022
🚀 Discord RPC Blocker for Lunar Client
🚀 Discord RPC Blocker for Lunar Client

?? Soyuz Soyuz has one simple purpose; listen for incoming Discord RPC requests from Lunar Client and block them! Limitations Windows only Soon to com

Oct 6, 2022
RPC based on C++ Workflow. Supports Baidu bRPC, Tencent tRPC, thrift protocols.
RPC based on C++ Workflow. Supports Baidu bRPC, Tencent tRPC, thrift protocols.

中文版入口 SRPC Introduction SRPC is an RPC system developed by Sogou. Its main features include: Base on Sogou C++ Workflow, with the following features:

Jan 3, 2023
Gromox - Groupware server backend with MAPI/HTTP, RPC/HTTP, IMAP, POP3 and PHP-MAPI support for grommunio

Gromox is the central groupware server component of grommunio. It is capable of serving as a replacement for Microsoft Exchange and compatibles. Conne

Dec 26, 2022
Fastest RPC in the west
Fastest RPC in the west

smf - the fastest RPC in the West We're looking for a new maintainer for the SMF project. As I have little time to keep up with issues. Please let me

Dec 28, 2022
Apache Thrift is a lightweight, language-independent software stack for point-to-point RPC implementation
Apache Thrift is a lightweight, language-independent software stack for point-to-point RPC implementation

Apache Thrift Introduction Thrift is a lightweight, language-independent software stack for point-to-point RPC implementation. Thrift provides clean a

Jan 7, 2023
FreeRDP is a free remote desktop protocol library and clients

FreeRDP is a free implementation of the Remote Desktop Protocol (RDP), released under the Apache license. Enjoy the freedom of using your software wherever you want, the way you want it, in a world where interoperability can finally liberate your computing experience.

Dec 31, 2022
An MQTT-based Virtual Wall for ESP8266 Devices and Gerber files to make the IR hat; this code and board can easily be adapted to be ANY infrared controller/remote!

Roomba-Virtual-Wall-ESP8266-MQTT An MQTT-based Virtual Wall for ESP8266 Devices I made this based off of the IRSend, IRremoteESP8266, and EspMQTTClien

Sep 20, 2021
A Hidden and Undetectable Remote Access Tool written in C++ and Server in Python3
A Hidden and Undetectable Remote Access Tool written in C++ and Server in Python3

Spyware-RAT A Hidden and Undetectable Remote Access Tool written in C++ and Server in Python3 This program utilizes the standard winsock library for s

Dec 25, 2022
Light and fast program for remote control of a computer.
Light and fast program for remote control of a computer.

DeskX - Remote control program About The project was created for its own use within the home local network (you can use DeskX over the internet using

Nov 28, 2022
Voicemeeter Remote API + Source Code Examples

Voicemeeter-SDK Voicemeeter Remote API + Source Code Examples Voicemeeter Remote API provides a set of functions to control Voicemeeter parameters, to

Dec 15, 2022
This is a remote controlled rover which I designed for my minor project.
This is a remote controlled rover which I designed for my minor project.

This is a remote controlled rover which I designed for my minor project. It is controlled remotely, wirelessly, over an internet connection using SSH. For further description, go through the codes :-)

Feb 1, 2022
Minimalistic server (written in C) and a python3 client to allow calling C function on a remote host

Minimalistic server (written in C) and a python3 client to allow calling C function on a remote host

Dec 30, 2022