procbridge
procbridge copied to clipboard
Communication has a big latency
Waiting for a server's response seems to normally take around ~5000ms.
How to reproduce:
I have tested this with the following scenario:
Client side (Kotlin(JVM)):
import co.gongzh.procbridge.Client
val procClient = Client(
"0.0.0.0",
8000
)
val start = System.currentTimeMillis()
procClient.request("ping", null)
println("Latency : ${System.currentTimeMillis() - start}ms")
Server side (Python):
import procbridge as pb
def handler(method, args):
if method == "initialtest1":
return "Initial test 1 triggered"
if method == "initialtest2":
return "Initial test 2 triggered"
if method == "echo":
return args
if method == "ping":
return "pong"
if __name__ == '__main__':
port = 8000
s = pb.Server('0.0.0.0', port, handler)
s.start(daemon=False)
print("Procbridge server is on {}...".format(port))
Run it several time or put it in a loop. You should get a similar result:
Latency : 5020ms
Latency : 1ms
Latency : 5001ms
Latency : 5009ms
Latency : 5003ms
Latency : 5004ms
Latency : 5004ms
Latency : 5003ms
Latency : 5004ms
Latency : 3ms
Latency : 2ms
Latency : 5008ms
Latency : 1ms
Latency : 5ms
Latency : 5008ms
Latency : 1ms
Latency : 1ms
Latency : 2ms
Latency : 5010ms
Latency : 5004ms
Latency : 5003ms
Latency : 5004ms
Latency : 5006ms
Latency : 5002ms
Hi, @astatio, thanks for the detailed description.
I took a quick look and it appears that something blocked and timed out at the 5 second mark. But I don't have a development environment at hand right now, can you help to confirm whether the blocking occurs on the server side or the client side? For example, you can set a breakpoint at procbridge/__init__.py#L126
and procbridge/__init__.py#L135
in the Python server-side program. The former is the location where the client request is received, and the latter is the location where the response data is sent.