Disconnecting From Qt VNC Server causes Segmentation Fault on Server - c++

I'm running my application with Qt 5.15.10 on Linux with VNC. I'm developing a Qt based VNC client but when disconnecting I encounter a segmentation fault on the server. This does not occur with existing vnc clients such as RealVNC and TightVNC.
Packet captures show I'm sending and receiving the FIN,ACK on the TCP socket and I'm also sending the final ACK same as the other two applications.
I've tried disconnecting using QAbstractSocket::disconnectFromHost() and just QAbstractSocket::close() with the same result.

Related

boost1.62 socket broken after reconnect in docker container

we have a c++ Application with boost1.62 and libssl1.0, that opens a TLS connection to a lighttpd Webserver (remote).
This works fine on any device we already rolled out. Now we are trying to use this application inside a container. The application starts up and everything is fine but.
When the connection gets reset for any reason, the application attempts to reconnect by making a new TCP-Connection with the socket.
Creating a HTTPS-Connection with TLS over that socket fails with EOF. Then the application tries to reconnect and gets the same fault -> endless reconnection loop.
I recorded the traffic and have seen the following:
Everything is alright
A TLS-Alert is recorded, sometimes also a TCP RESET.
Client sends SYN
Server sends SYN ACK
Client sends ACK
Client sends FIN, ACK
Server sends ACK
Server sends FIN, ACK
Client sends ACK
Steps 3 to 7 occur in less than 3 ms.
as soon as Step 7 has passed, a new connection is made starting with step 3.
I'm using an ubuntu 18.04 on host and as base image. (Both x64)
Both host and container use the same libraries. Therefore i think its not an issue with used libraries.
The application runs in production for over a year on several arm32v7 and x64 devices. This error never occurred then.
Oddly, if the application is configured to use plain HTTP instead HTTPS, the error does not occur.
Any suggestions what this might be? Based on my knowledge i can rule out the following:
wrong dependencies
misconfigured Kernel (container and host use the same)
Thanks for your help
After a disconnect, we reused the old socket. This works flawless outside docker. Inside docker it produces the described behaviour.
Workaround: delete the broken socket and create a new one.
This is bad for performance though.

boost asio notify server of disconnect

I was wondering if there is any way to notify a server if a client side application was closed. Normally, if I Ctrl+C my client side terminal an EOF-signal is sent to the server side. The server side async_read function has a handle which has boost::system::error_code ec argument fed into it. The handle is called when the server side receives EOF-signal which I can happily process and tell the server to start listening again.
However, if I try to cleanly close my client application using socket.shutdown() and socket.close() nothing happens and the server side socket remains open.
I was wondering, is there a way to somehow send an error signal to the server-side socket so I could then process it using the error code?
The approaches described in comments covers 99% of cases. It doesn't work when client machine was (not gracefully) turned off, or network problems.
To get reliable notification of disconnected client you need to implement "ping" feature: to send ping packets regularly and to check that you received pong packets.

Re-connecting to QDBus server after server has been restarted (Qt C++)

I'm testing out using DBus for inter process communication for an QT C++ project (Linux).
I'm not using the bus daemon and i'm using unix paths / sockets.
After navigating my way through the mysterious world that is QT DBUS all seemed to be going well, until i wanted to test the robustness of one of my interfaces.
After killing the server process en restarting it, the connection times out.. i cleanup the connection objects (client-side) and i try to re-connect to the server.
The client does not seem to be able to reconnect and i get the following errors:
errName: org.freedesktop.DBus.Error.NoServer
errMesage: Failed to connect to socket /tmp/abcd: Connection refused
Ive tried:
- QDBusConnection::disconnectFromPeer(addr);
- cleaning up all related object, so no references to the connection exist.
When i restart the client, it has no problems connecting to the (restarted) server.
Problem found!
Seems to be a bug in Qt 4.8.x:
https://bugreports.qt.io/browse/QTBUG-27973
https://codereview.qt-project.org/#/c/60709/
QDBusConnection::disconnectFromBus and QDBusConnection::disconnectFromPeer does not remove invalid connection

Cant receive packets with UDP and SFML

I am having problems trying to get UDP to work with SFML in C++.
I have made a client class and a server class.
The server can send text messages and the client can receive and print them.
Server and client runs in the seperate threads.
The problem is, it is not working on LAN.
If I have the client and server running in seperate windows on the same computer I can send messages just fine, but if the server runs on one computer and the client on another on the same LAN, the messages aren't received.
I hope someone can help.
Thank you in advance.

Check remote host state in a nework using Indy comps

I have client server application that works with Firebird server. Everytime when clients connect to the server they(client apps) don't check if there is a network connection to the server so at this time my application sometimes freezes when the server computer is switched off or service has stopped, so first of all I need to check connection if remote host is switched on or at some port anything listening....
Before establishing the connection I need to check it and make sure server and service is running using Indy components.
Any ideas? also I can use IcmpClient to ping remote host and then establish connection but which is the most optimal way ?
If you just want to check if the server computer can be reached, you could do a "ping" to check that. However, if you want to check if a specific TCP port is open, then the only way to find that out is to actually do a proper connect, which leads to the "freezing" program while the connection times out if there is no-one listening on that port.