jcon-cpp icon indicating copy to clipboard operation
jcon-cpp copied to clipboard

no answer from server on really fast computers

Open sancelot opened this issue 5 years ago • 7 comments

Hi, I had a client (python) / server (jcon) program running fine in a windows 7 computer.

I launched the same program on a really fast computer (3Ghz) and the requests are not seen from the server side . The socket is connected, but there is no answer from server when making client requests.

What could be the problem ?

sancelot avatar Oct 27 '20 08:10 sancelot

Hi, can you tests with the small example in src/main.cpp? If that works, maybe make a minimal server and try with your Python client against that? If you get something minimal that doesn't work, I could try reproducing it. It's hard to guess what could be wrong otherwise.

joncol avatar Oct 27 '20 09:10 joncol

I will try a single unittest using only jcon client / server. I setted up log interface too. I am not sure at the moment, but I think we may reach JsonRpcEndpoint::dataReady() , but are we sure the whole data is there at this moment , or only a chunk ?

sancelot avatar Oct 27 '20 09:10 sancelot

Only a chunk. See documentation of the readyRead() signal on https://doc.qt.io/qt-5/qabstractsocket.html.

joncol avatar Oct 27 '20 09:10 joncol

This sounds to be another kind of problem, running the small exemple program , the log is :

so, I will check if a process uses that port...

JSON RPC server: listening on port 6002 JSON RPC server error: Error listening on port 6002

client : connecting to JSON RPC server at 127.0.0.1:6002 connected to JSON RPC server 127.0.0.1:6002 (local port: 49475) Calling (async) RPC method: 'getRandomInt' with argument: 10 (request ID: f084a8af-7fd2-42d7-a37a-533aa076f9df) Calling (sync) RPC method: 'getRandomInt' with argument: 100 (request ID: c5708e78-8cf0-4651-b3ec-103e13e2c05a) cannot call RPC method (printMessage) when not connected Calling (sync) RPC method: 'printMessage' with argument: hello, world (request ID: 069cae7e-3b60-4003-92a8-5180dc06457c)

sancelot avatar Oct 28 '20 12:10 sancelot

Hi, "server error: Error listening" seems to indicate your port 6002 might already be in use. Try : sudo lsof -i -P -n | grep LISTEN | grep 6002

Edit: netstat -a -b | findstr 6002 in an elevated command prompt on Windows

On the other hand I added an auto try to connect feature on the client side on top of jcon because if the client is started before the server it fails to connect. On a fast machine the order of process launch may differ.

Best regards

kaloskagatos avatar Oct 28 '20 13:10 kaloskagatos

netstat -aon | findstr 6002 to find the process id , and then tasklist /fi "pid eq XXXX" to find the process.

There is a process named spnsvrt.exe using this port :worried:

sancelot avatar Oct 29 '20 09:10 sancelot

Hi, you can choose whatever free port you want from 1024 to 65535. Try 6003 ;)

You can find a free port by using (edit) QTcpSocket::localPort() : https://stackoverflow.com/questions/34678938/platform-independent-qt5-way-to-get-open-tcp-port

You can start your server or client passing the port as an argument on the command line.

Best regards

kaloskagatos avatar Oct 29 '20 09:10 kaloskagatos