communi / libcommuni

A cross-platform IRC framework for Qt
https://communi.github.io
BSD 3-Clause "New" or "Revised" License
84 stars 38 forks source link

ping timeout on ssl connections #121

Open ernibert opened 4 months ago

ernibert commented 4 months ago

Hi, I've implemented a client which connects via SSL to libera.cat (irc.libera.chat/6697).

It looks like the client has some issues with ping/pong as it constantly disconnects (server reports "qtirc hat die Verbindung getrennt (Ping timeout: 256 seconds)". It occurs 3 minutes after connecting, sometimes after 25 min even though i see that the client does emit debug output doing the PING-PONG dance. It looks like

[08:42] * qtirc (~qtirc@blahblah.t-ipconnect.de) hat #channel betreten
[09:13] * qtirc hat die Verbindung getrennt (Ping timeout: 264 seconds)

This client does not use the buffer model, i maintain GUI elements by my own.

Interesting enough, i have tweaked the example client of the libcommuni package by adding

    connection->setSecure(true);
    connection->setPort(6697);

to void IrcClient::createConnection() and with that, the sample client does not show the ping-pong timeout (at least in a reasonable amount of time) show same behavior (first i thought it wouldn't, but it does).

My client connects also to a (local) irc server on 6667 (no SSL) and the ping-timeout issue does not occur on this connection. So i assume it has something to with SSL connections, but i have no idea how to proof that. On a connection via 6667/no-ssl to irc.libera.chat does not show any issues, too.

So, it looks like

I'm totally confused...

Please tell me which parts of the source I should provide in case you will want to help me but more details about the implementation is required.

Issue #85 sounds like addressing same problem but unfortunatly, no further discussion/details at that ticket.

ernibert commented 3 months ago

It looks like this is not a client-side issue. I've experimented with this and that, set socket options (SO_KEEPALIVE) and such, nothing helped.

The big question was: Why does our client behaves this way while XChat/HexChat doesn't? At the moment, it looks like that the answer is: Because they do conversation initiated by the client.

{X,Hex}chat do a /WHO command on a regular basis, i think for updating their internal user-db. I added a timer to my client which does a "/WHO *" every 2 minutes, too, and e voila, the client stays connected for 12h now. Previously, it got disconnected after a few minutes.