Skip to content

tcp client disconnection #39

Description

@sancelot

Hi,
Using a tcp rpc client connection there seems being a disconnection after a while, if we don't send commands.

the call() replies with not connected

Is there an automatic disconnect ? That was the first problem.

I have tried using jcon client with many python json tcp servers. unfortunately most of them are not able to reliably communicate with jcon !!!!!

Finally I found this working API : https://github.com/joshmarshall/jsonrpctcp

It works , BUT... It is not possible to send 2 calls without disconnecting the client from the server and initiating a new connection.

The code for client side is :

int main(int argc, char* argv[])
{
    QCoreApplication app(argc, argv);

    {
        auto rpc_client = startClient(&app, SocketType::tcp);
	auto result = rpc_client->call("AppendProd","Production",1,32);
        if (result->isSuccess()) {
           qDebug() << "result of synchronous RPC call:" << result->result();
       } else {
         qDebug() << "RPC error:" << result->toString();
      }  
       result = rpc_client->call("AppendProd","Prduction",1,325);
      if (result->isSuccess()) {
        qDebug() << "result of synchronous RPC call:" << result->result();
       } else {
        qDebug() << "RPC error:" << result->toString();
      }

    }
}

the python code for server side is :

from jsonrpctcp.server import Server
from jsonrpctcp import config
from jsonrpctcp import logger
import thread,threading

def AppendProd(type_,m,n):
    print "type",type_,m,n
    return ("Hello",10,11,12,True)

server=Server(('localhost',6002))

import logging
config.verbose = True
logger.addHandler(logging.StreamHandler())
logger.setLevel(logging.DEBUG)
       

server.add_handler(AppendProd)
server_thread = threading.Thread(target=server.serve)
server_thread.daemon = True
server_thread.start()

import time
while True:
    time.sleep(0.5)

What is the way to log on the jconcpp side ? There is a jcon_client_log.txt file generated, but is empty !

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions