philippseith / signalr

SignalR server and client in go
MIT License
140 stars 40 forks source link

Python client disconnects after upgrading to v0.6.3 #178

Closed renato-kristic closed 1 year ago

renato-kristic commented 1 year ago

I upgraded golang SignalR server to version 0.6.3 and noticed that my Python SignalR clients are disconnecting after 30-35 seconds. It is something related to keepAlive parameter. This is what I configured for my server:

signalr.KeepAliveInterval(15*time.Second),
signalr.TimeoutInterval(30*time.Second),

This is what I configured to Python client:

config = {
            "keep_alive_interval": 15,
            "reconnect_interval": 5
        }

After python client disconnects I get this message from golang server: level=debug ts=2023-09-21T07:54:21.292862254Z protocol=JSON caller=jsonhubprotocol.go:211 event=write message="{\"type\":7,\"error\":\"timeout interval elapsed (30s)\",\"allowReconnect\":true}\u001e"

I tried lowering keep_alive_interval for python client and when value is lower than 5 (For example 4s) it is working correctly. With keep_alive_interval: 4 value I can see that server receives heartbeat message every 4 seconds: level=debug ts=2023-09-21T09:07:26.263254545Z class=Server connection="lHXJNjVgYRMzOedLe0grhA==" hub=test.LPSHub caller=loop.go:282 event="message received" message=signalr.hubMessage{Type:6} If value is >=5 I cannot see that these messages arrive on server.

When testing this with golang client everything is working great. Heartbeat messages arrive every 15s and client never gets disconnected.

Any idea what is causing these issues in v0.6.3?

philippseith commented 1 year ago

From which version did you upgrade to 0.6.3? Can you see the keep alive messages with the old server version with keep_alive_interval > 5 sec?

philippseith commented 1 year ago

It might be bace5a6e0450272c6377b9a48f1dbf0f259b8f0d which fixed the bug that the server itself reseted its timeout when it sent a ping to the client. This in turn would mean that the python client is not sending keepalives when the span is > 4 sec. Is it a bug in the python client?

renato-kristic commented 1 year ago

Yes @philippseith you are right. Upgrading from 0.6.2 to 0.6.3 resulted in these issues. But this only revealed bug in Python client. I used https://github.com/mandrewcito/signalrcore (0.8.5) and I can confirm that this version is not sending Ping when keep_alive_interval>=5 After upgrading Python signalrcore to the latest version (0.9.5) I solved these issues.