Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Unsolved Correct way to setup proxy of QNetworkAccessManager

    General and Desktop
    2
    7
    3350
    Loading More Posts
    • 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.
    • tham
      tham last edited by

      Is this a correct way to setup the proxy?I found the proxies list at here, I only pick the proxy do not need password and username

      QNetworkProxy proxy;
      proxy.setType(QNetworkProxy::HttpProxy);
      proxy.setHostName("82.207.118.163");
      proxy.setPort(3128);
      manager->setProxy(proxy);
      

      The manager can download the images(those links all start with http) and the speed become much slower compare with the cases without proxy setting(sounds like it really go through the proxy?), is this a correct sign?

      If this is correct solution, how could I download/access websites with more than one proxy?
      my pc->proxy A->proxy B
      proxy B->proxy A->my pc

      Is this possible to be done by Qt5?Thanks

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi,

        You'd have to use several QNAM each with its own proxy.

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

        tham 1 Reply Last reply Reply Quote 0
        • tham
          tham @SGaist last edited by

          @SGaist said in Correct way to setup proxy of QNetworkAccessManager:

          You'd have to use several QNAM each with its own proxy.

          Do you mean download/access websites with more than one proxy?
          Could you show me an example how to do it? Thanks

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            No, i mean use several QNetworkAccessManager (guess based on your variable name) objects. And you change the proxy for each of them.

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

            tham 1 Reply Last reply Reply Quote 0
            • tham
              tham @SGaist last edited by tham

              @SGaist said in Correct way to setup proxy of QNetworkAccessManager:

              No, i mean use several QNetworkAccessManager (guess based on your variable name) objects. And you change the proxy for each of them

              According to the document of setProxy(QNetworkAccessManager)

              the proxy to be used in future requests to be proxy. This does not affect requests that have already been sent.

              I think It should be fine even I change the proxy every time I open a new request based on the doc?

              1 Reply Last reply Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                IIRC, QNAM handles up to 6 request at the same time, the others are then queued and processed as soon as one finishes. So I don't know whether "sent" means also queued for later or just the currently working request.

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

                tham 1 Reply Last reply Reply Quote 0
                • tham
                  tham @SGaist last edited by

                  @SGaist said in Correct way to setup proxy of QNetworkAccessManager:

                  IIRC, QNAM handles up to 6 request at the same time, the others are then queued and processed as soon as one finishes. So I don't know whether "sent" means also queued for later or just the currently working request.

                  I see, thanks for this info, it is fine with me, because I can queue the settings of proxies by myself.

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post