<div dir="auto"><span style="font-family:sans-serif;font-size:12.8px">That's the thing. I already handle connections and disconnections in my code - including logging relevant information.</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">When I implemented this I heavily based on the example that you linked to.</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">WSS communication is single threaded - only way to communicate with the outside world from different thread is to send custom QEvent onto the Server instance.</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">QWebSocketServer does not seem to have the method incomingConnection in it's public API or maybe I already went mad :P I react to the QWebSocketServer::newConnectio</span><span style="font-family:sans-serif;font-size:12.8px">n signal.</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">Last RST from client at 33 second mark is our client-side timeout.</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">This is the code that handles websocket stuff, I have stripped some parts that are less important:</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">// server connects</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">connect(m_wsServer, &QWebSocketServer::acceptError</span><span style="font-family:sans-serif;font-size:12.8px">, this, [this](QAbstractSocket::Socket</span><span style="font-family:sans-serif;font-size:12.8px">Error socketError) {</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        qCritical() << "QWebSocketServer - acceptError:" << socketError;</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">});</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">connect(m_wsServer, &QWebSocketServer::peerVerifyE</span><span style="font-family:sans-serif;font-size:12.8px">rror, this, [this](const QSslError& error) {</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        qCritical() << "QWebSocketServer - peerVerifyError:" << error;</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">});</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">connect(m_wsServer, &QWebSocketServer::serverError</span><span style="font-family:sans-serif;font-size:12.8px">, this, [this](QWebSocketProtocol::Clo</span><span style="font-family:sans-serif;font-size:12.8px">seCode closeCode) {</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        qCritical() << "QWebSocketServer - serverError:" << closeCode;</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">});</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">connect(m_wsServer, &QWebSocketServer::sslErrors, this, [this](const QList<QSslError>& errors) {</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        qCritical() << "QWebSocketServer - sslErrors:" << errors;</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">});</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">connect(m_wsServer, &QWebSocketServer::closed, this, [this]() {</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        qCritical() << "QWebSocketServer - closed, serverError():" << m_wsServer->errorString();</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">});</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">connect(m_wsServer, &QWebSocketServer::newConnecti</span><span style="font-family:sans-serif;font-size:12.8px">on, this, [this]() {</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        QWebSocket* clientSocket = m_wsServer->nextPendingConnect</span><span style="font-family:sans-serif;font-size:12.8px">ion();</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        qInfo() << "Got connection from client:" << clientSocket->peerAddress();</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        [ client initialization stuff ]</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        connect(clientSocket, &QWebSocket::binaryMessageRece</span><span style="font-family:sans-serif;font-size:12.8px">ived, this, [this](const QByteArray& message) {</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">                auto client = sender()->property("client").v</span><span style="font-family:sans-serif;font-size:12.8px">alue<Client*>();</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">                [ message deserialization ]</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        });</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        connect(clientSocket, &QWebSocket::disconnected, this, [this]() {</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">                auto client = sender()->property("client").v</span><span style="font-family:sans-serif;font-size:12.8px">alue<Client*>();</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">                qInfo() << client->sayHello() << "is disconnected.";</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">                client->handleDisconnection();</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">                [ clinet cleanup stuff ]</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        });</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">});</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">Client's handleDisconnection() function does:</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">void i9ms::Client::handleDisconnect</span><span style="font-family:sans-serif;font-size:12.8px">ion()</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">{</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        m_isConnected = false;</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        m_websocket->deleteLater();</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">        m_websocket   = nullptr;</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">}</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">Nothing from this lands in system logs. It seems that QWebSocketServer::newConnectio</span><span style="font-family:sans-serif;font-size:12.8px">n() is just not emited.</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">As I wrote earlier I have a timerEvent that logs QWebSocketServer's state - once every ten minutes.</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">It happily reports that server is listening, has no pending connections and it's internal 'errorString' is empty - even if it is mute from the outside.</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">It's hard for me to pinpoint exactly what causes this. 'Time' is my best guess.</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">I'm also not sure if quantity of connections plays a role here.</span><br style="font-family:sans-serif;font-size:12.8px"><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">I have a 'fuzzer-bot' that spams hundreds of connections and messages at the server in short period of time.</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">Malformed messages, out-of-order client state changes, ugly words - you name it we have it.</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">QWebSocketServer handles it well enough for us but then, at some time in future WHILE being completely idle, server goes silent.</span><br style="font-family:sans-serif;font-size:12.8px"><span style="font-family:sans-serif;font-size:12.8px">On the other hand I can start the server, connect - disconnect one client, leave it for a while in idle and same thing happens, leaving me one step closer to dementia.</span><br><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Wed, 3 Apr 2019, 22:32 Jason H, <<a href="mailto:jhihn@gmx.com">jhihn@gmx.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-family:Verdana;font-size:12.0px">
<div dir="auto">Addendum, </div>

<div dir="auto"> </div>

<div dir="auto">How much does you code diverge from the example? <a href="https://doc.qt.io/qt-5/echoserver.html" target="_blank" rel="noreferrer">https://doc.qt.io/qt-5/echoserver.html</a></div>

<div dir="auto">Can you hack that to receive your traffic or augment your code to to do what it does?</div>

<div dir="auto">Note that the QWebSocket server does not take ownership of the QWebSocket, you have to track that manually. Using the code they provide, I would also log your connected clients. See the slot
<pre> EchoServer::socketDisconnected()</pre></div>
</div></div>
</blockquote></div></div>