Fortune Server/Client Example does not work remote
I want to control a GUI running on a Raspberry PI remotely from a computer connected via local ethernet link.
I found the fortune server / fortune client examples from the Qt Network module.
This example is running nice as long as I'm running the server and the client on the same host (Laptop (Qt 5.7.1 amd64 GNU/Linux) or Raspbian (Qt 5.3.2 armhf Linux)). If I try to connect from one host to the other, I receive no fortune. If the IP or the port is invalid, I receive a error. If both are valid there is just no fortune.
Is there a bug, or do I have to adapt the example for my purpose?
Is this example a good starting point for implementing a fast and simple signaling between two local linked hosts?
Thanks for your suggestions.
Did you check the TCP connection between the server(windows ) and client(raspberry)?
- I would recommend first try with ping command. Make sure that both are connected
- No more firewall blocks.
- Try to debug with wireshark. To know where the packet is going.
The example should work.
There should no firewalls be running. On my Laptop no firewall is set up and also on the Raspberry PI there is no firewall set up by default.
I'm connecting to the Raspberry via VNC, so there is a link for sure.
So I can't imaging that packets could be blocked. Nevertheless I will try to investigate wireshark.
as soon I send a single first request, the data packages are going back and forth and fortunes are send (monitoring at the server host). As soon I'm closing the server, I get some errors and the client takes note and shows a connection error.
Therefore I assume, that the client does not handle the received data correctly.
which means there is a connection problem.
Try to bebug it.
check if the connection is success or not
check emit readyRead() signal is emitted or not by connecting it to a slot.
I investigated the issue: the examples from Qt 5.3.2 and Qt 5.7.1 are not compatible. If I run the 5.3.2 example on both hosts, it works. I have not checked with the 5.7.1 example, as it relies on new calls.
in each cases
setVersion(QDataStream::Qt_4_0);is called. This is not the difference. I realized with wireshark, that there is a different amount of data bytes before the characters are starting (4 resp. 6 bytes), but I have not investigated this further.
in the Qt 5.3.2 version the data is headered by a
(quint16)0;and trailed by
(quint16)(block.size() - sizeof(quint16));. This bytes are removed in the Qt 5.7 version with the introduction of the
startTransaction()method in 5.7.
Ok. was just a thought. I was bitten mixing at one point but seems to use the same version so you already checked this.