Skip to content

Reply pong to ping messages#20

Closed
corentincam wants to merge 1 commit into
shadowylab:masterfrom
corentincam:respect-ping-pong
Closed

Reply pong to ping messages#20
corentincam wants to merge 1 commit into
shadowylab:masterfrom
corentincam:respect-ping-pong

Conversation

@corentincam

Copy link
Copy Markdown
Contributor

I've been using the subscribing part for some time now and I noticed that after a long period of time the subscribers silently lose the connection. I believe that's because the server is sending ping messages that are never replied with a pong (see this).

This little patch fixes that, I tested it and it works but I will know if the main issue of losing connection is fixed only in a few hours if I don't forget to test it.

@corentincam

Copy link
Copy Markdown
Contributor Author

My subscriber haven't lost the connection for more than 5 hours. The fix seems to work.

@yukibtc

yukibtc commented May 5, 2026

Copy link
Copy Markdown
Member

Thanks @corentincam

I see that tungstenite says this in docs:

upon receiving ping messages tungstenite queues pong replies automatically. The next call to read, write or flush will write & flush the pong reply. This means you should not respond to ping frames manually.

I've added a unit test at commit 967c5f3 and the stream automatically replies to pings.

@corentincam

corentincam commented May 11, 2026

Copy link
Copy Markdown
Contributor Author

You're right, also my problem is still present with my patch so it doesn't seem to come from that...

I don't understand why my subscriber disconnects after a few hours, I'll investigate more.

This PR can be discarded

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

Successfully merging this pull request may close these issues.

2 participants