Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSslSocket::readyRead() never triggered with Python server

QSslSocket::readyRead() never triggered with Python server

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 4 Posters 2.6k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ArtiFAS
    wrote on last edited by ArtiFAS
    #3

    @SGaist Yes I did,

    I see all of the TLS Handshake being done successfully.

    The server then sends data to the client after a client request and it looks like the client acknowledges those packets.

    The IP .19 is the client and the .103 is the server. There are many SSH packets since my client has an ssh session opened with the server. The ports are the right ones.

    capture1.png

    capture2.png

    capture3.png

    There's a fourth screenshot of the packets,but I'm not sure it is relevant.

    Kent-DorfmanK 1 Reply Last reply
    0
    • A ArtiFAS

      @SGaist Yes I did,

      I see all of the TLS Handshake being done successfully.

      The server then sends data to the client after a client request and it looks like the client acknowledges those packets.

      The IP .19 is the client and the .103 is the server. There are many SSH packets since my client has an ssh session opened with the server. The ports are the right ones.

      capture1.png

      capture2.png

      capture3.png

      There's a fourth screenshot of the packets,but I'm not sure it is relevant.

      Kent-DorfmanK Offline
      Kent-DorfmanK Offline
      Kent-Dorfman
      wrote on last edited by
      #4

      @ArtiFAS

      Just being nitpicky, but technically it's not an ethernet receiver. There is no requirement that it have anything to do with ethernet. The SSL connection is over TCP (layer 4) and ethernet is a layer (1/2) service. IP need not be carried over ethernet.

      I think you may be making it too complicated by using threads...and I question the need for mutex locks if you get rid of the threads.

      If you need to service multiple connections, the long standing UNIX way is to fork a new instance of your program for each connection.

      If you meet the AI on the road, kill it.

      jsulmJ A 2 Replies Last reply
      0
      • Kent-DorfmanK Kent-Dorfman

        @ArtiFAS

        Just being nitpicky, but technically it's not an ethernet receiver. There is no requirement that it have anything to do with ethernet. The SSL connection is over TCP (layer 4) and ethernet is a layer (1/2) service. IP need not be carried over ethernet.

        I think you may be making it too complicated by using threads...and I question the need for mutex locks if you get rid of the threads.

        If you need to service multiple connections, the long standing UNIX way is to fork a new instance of your program for each connection.

        jsulmJ Offline
        jsulmJ Offline
        jsulm
        Lifetime Qt Champion
        wrote on last edited by
        #5

        @Kent-Dorfman said in QSslSocket::readyRead() never triggered with Python server:

        the long standing UNIX way is to fork a new instance of your program for each connection

        The Qt way is to use assynchronous nature of Qt with signals/slots :-)

        https://forum.qt.io/topic/113070/qt-code-of-conduct

        Kent-DorfmanK 1 Reply Last reply
        0
        • jsulmJ jsulm

          @Kent-Dorfman said in QSslSocket::readyRead() never triggered with Python server:

          the long standing UNIX way is to fork a new instance of your program for each connection

          The Qt way is to use assynchronous nature of Qt with signals/slots :-)

          Kent-DorfmanK Offline
          Kent-DorfmanK Offline
          Kent-Dorfman
          wrote on last edited by
          #6

          @jsulm said in QSslSocket::readyRead() never triggered with Python server:

          The Qt way is to use assynchronous nature of Qt with signals/slots :-)

          SPOILER!

          Haven't you heard of making the student to it by brute force before showing them the easy way?

          If you meet the AI on the road, kill it.

          SGaistS 1 Reply Last reply
          0
          • Kent-DorfmanK Kent-Dorfman

            @jsulm said in QSslSocket::readyRead() never triggered with Python server:

            The Qt way is to use assynchronous nature of Qt with signals/slots :-)

            SPOILER!

            Haven't you heard of making the student to it by brute force before showing them the easy way?

            SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #7

            @Kent-Dorfman said in QSslSocket::readyRead() never triggered with Python server:

            @jsulm said in QSslSocket::readyRead() never triggered with Python server:

            The Qt way is to use assynchronous nature of Qt with signals/slots :-)

            SPOILER!

            Haven't you heard of making the student to it by brute force before showing them the easy way?

            Well, I am not a fan of teaching the youngster about the screwdriver after they broke their fingers with a sledgehammer.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            Kent-DorfmanK 1 Reply Last reply
            0
            • SGaistS SGaist

              @Kent-Dorfman said in QSslSocket::readyRead() never triggered with Python server:

              @jsulm said in QSslSocket::readyRead() never triggered with Python server:

              The Qt way is to use assynchronous nature of Qt with signals/slots :-)

              SPOILER!

              Haven't you heard of making the student to it by brute force before showing them the easy way?

              Well, I am not a fan of teaching the youngster about the screwdriver after they broke their fingers with a sledgehammer.

              Kent-DorfmanK Offline
              Kent-DorfmanK Offline
              Kent-Dorfman
              wrote on last edited by
              #8

              @SGaist said in QSslSocket::readyRead() never triggered with Python server:

              Well, I am not a fan of teaching the youngster about the screwdriver after they broke their fingers with a sledgehammer.

              Eh, I wouldn't consider that to be a fair analogy. fork() is easier to implement, and teaches more fundemental theory, while being less efficient.

              If you meet the AI on the road, kill it.

              SGaistS 1 Reply Last reply
              0
              • Kent-DorfmanK Kent-Dorfman

                @SGaist said in QSslSocket::readyRead() never triggered with Python server:

                Well, I am not a fan of teaching the youngster about the screwdriver after they broke their fingers with a sledgehammer.

                Eh, I wouldn't consider that to be a fair analogy. fork() is easier to implement, and teaches more fundemental theory, while being less efficient.

                SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #9

                @Kent-Dorfman agreed, but when you use a framework, learn the framework and what it provides rather than try to make it fit your habits.
                Since it's Qt, the networking stuff rarely needs any threading or forking.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                1
                • Kent-DorfmanK Kent-Dorfman

                  @ArtiFAS

                  Just being nitpicky, but technically it's not an ethernet receiver. There is no requirement that it have anything to do with ethernet. The SSL connection is over TCP (layer 4) and ethernet is a layer (1/2) service. IP need not be carried over ethernet.

                  I think you may be making it too complicated by using threads...and I question the need for mutex locks if you get rid of the threads.

                  If you need to service multiple connections, the long standing UNIX way is to fork a new instance of your program for each connection.

                  A Offline
                  A Offline
                  ArtiFAS
                  wrote on last edited by ArtiFAS
                  #10

                  @Kent-Dorfman
                  Agreed, it could be used with any Data-Link Layer protocol, but in this specific project, it is only used over Ethernet, hence the name choice.

                  I've decided to thread the Sender as a personal challenge, but I understand it's more complicated than it could be, I'm totally fine with it.

                  As for the Receiver, all messages are received asynchronously (at any given moment, the Rock Pi E, the server, could send a new message on the socket). That is why I decided to thread this bit. The Rock Pi can also send big payloads (100MB) separated in many smaller messages (as it should). Parsing them is too much of load for the signal's thread, so I implemented my own Producer-Consumer structure, which I think is fair enough in this case.

                  As for the forks, I don't think they're totally appropriate for what I'm trying to achieve. The app's main goal is efficiency and lightness. I will explore this avenue, but I doubt it's the easiest/fastest way to achieve my goals since the app must be usable on Windows and Linux.

                  Thanks for the advice!

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    ArtiFAS
                    wrote on last edited by ArtiFAS
                    #11

                    I've dig up a little more and found that using the QSslSocket::waitForReadyRead() method 5 secs after sending the message actually returns true. I then read the socket with socket->readAll() and messages have been received (they're valid!). The signal still isn't being triggered though... Must waitForReadyRead be called for the signal to be triggered? I've read that these are separate, but I'm not sure about their behavior...

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #12

                      One of the issue is that you have while loop that will block Qt's event loop processing. Don't use such a loop as Qt is an event driven framework. You should implement proper signal and slot handling so that you trigger the next command sending after the last one. You can use a 0 based QTimer for example.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      A 1 Reply Last reply
                      1
                      • SGaistS SGaist

                        One of the issue is that you have while loop that will block Qt's event loop processing. Don't use such a loop as Qt is an event driven framework. You should implement proper signal and slot handling so that you trigger the next command sending after the last one. You can use a 0 based QTimer for example.

                        A Offline
                        A Offline
                        ArtiFAS
                        wrote on last edited by
                        #13

                        @SGaist I'm not totally sure which while loop you are refering to. There's one in the EthernetReceiver::processData() method and one in the EthernetSender::processCommand() method. Both of these methods are called in a separate thread which is woke previously in the EthernetSender::sendCommand(Command) and the EthernetReceiver::socketReadyRead() methods. In both case, the loops are not affecting the return time of the readyRead() signal.

                        I'm not sure I've understood fully what you're proposing, but let me know if this comment is relevant or not.

                        SGaistS 1 Reply Last reply
                        0
                        • A ArtiFAS

                          @SGaist I'm not totally sure which while loop you are refering to. There's one in the EthernetReceiver::processData() method and one in the EthernetSender::processCommand() method. Both of these methods are called in a separate thread which is woke previously in the EthernetSender::sendCommand(Command) and the EthernetReceiver::socketReadyRead() methods. In both case, the loops are not affecting the return time of the readyRead() signal.

                          I'm not sure I've understood fully what you're proposing, but let me know if this comment is relevant or not.

                          SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #14

                          @ArtiFAS That's one of the issue with the code sample you gave. There's not enough context to fully understand how it is working.

                          Now the question is: why do you need a separate thread to handle your network connection ? Most of the time there's no need for that as Qt is asynchronous.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          1

                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • Users
                          • Groups
                          • Search
                          • Get Qt Extensions
                          • Unsolved