Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tcp client disconnection #39

Open
sancelot opened this issue Apr 11, 2019 · 2 comments
Open

tcp client disconnection #39

sancelot opened this issue Apr 11, 2019 · 2 comments

Comments

@sancelot
Copy link

sancelot commented Apr 11, 2019

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 !

@sancelot sancelot changed the title tcp server disconnection tcp client disconnection Apr 11, 2019
@joncol
Copy link
Owner

joncol commented Apr 11, 2019

Can you create a minimal example where you demonstrate the problems with connections automatically going down? It could be a result of the server automatically closing the socket. There should be no such mechanism in the client code.

There's a JsonRpcFileLogger class which logs to file. I'm not sure what your question is regarding the logging.

@sancelot
Copy link
Author

sancelot commented Apr 11, 2019

I tried the same thing using the jconcpp server usi ng 2 distincts program, I have not found the problem with needing to disconnect before sending new call request.

I checked server side in the jsonrpctcp api , and it closes the socket with each request !
(https://github.com/joshmarshall/jsonrpctcp/blob/master/jsonrpctcp/server.py#L195) so, connecting again is mandatory . But on jconcpp client in this case , I don't seem to have the notification of socket closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants