Important: Please read the Qt Code of Conduct -

Fortune Server/Client Example does not work remote

  • Hello,

    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.

  • @qmmj
    Did you check the TCP connection between the server(windows ) and client(raspberry)?

    1. I would recommend first try with ping command. Make sure that both are connected
    2. No more firewall blocks.
    3. Try to debug with wireshark. To know where the packet is going.

    The example should work.

  • @vishnu
    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.

  • Hmm,

    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.

    1. after tcpSocket->connectToHost(hostCombo->currentText(),
      check if the connection is success or not

    2. check emit readyRead() signal is emitted or not by connecting it to a slot.

  • Hi vishnu,

    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.

  • Lifetime Qt Champion

    Purely speculation but
    If you mix Qt 5.3 and 5.7
    Maybe its related to
    Didnt check if qdatastream is involved in the fortune examples :)

  • @mrjj:
    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.

  • @mrjj:
    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.

  • Lifetime Qt Champion

    Ok. was just a thought. I was bitten mixing at one point but seems to use the same version so you already checked this.

Log in to reply