Results 1 to 5 of 5

Thread: QNetworkAccessManager finished() isn't emitted after the 2nd request when SSL error

  1. #1
    Join Date
    Apr 2020
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default QNetworkAccessManager finished() isn't emitted after the 2nd request when SSL error

    Hi!
    I'm trying to use QNetworkAccessManager to download files over https. And I found a strange thing: if the SSL libraries are not available to my application, then, as expected, the QNetworkAccessManager::get() request causes the QNetworkAccessManager::finished(QNetworkReply*) signal to be emitted. Inside the slot connected to this signal, I can read the error status (QNetworkReply::error()) and understand that the "TLS initialization failed" error occurred.
    It's ok, but this is only the first time. If I make repeated attempts to execute QNetworkAccessManager::get(), the finished() signal is not emitted.
    Why is that? I would like to get at least some response from QNetworkAccessManager on every request.

    P.S. QNetworkReply::error() is not emitted too.

    My system is Windows 10, Qt 5.14.1

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,734
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QNetworkAccessManager finished() isn't emitted after the 2nd request when SSL err

    Quote Originally Posted by Dmitro25 View Post
    P.S. QNetworkReply::error() is not emitted too.
    ... and the QNetworkReply::sslErrors() signal ?

  3. #3
    Join Date
    Apr 2020
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QNetworkAccessManager finished() isn't emitted after the 2nd request when SSL err

    Quote Originally Posted by ChrisW67 View Post
    ... and the QNetworkReply::sslErrors() signal ?
    Signal QNetworkReply::error() is only emitted for the first time (with code==QNetworkReply::UnknownNetworkError); signal QNetworkReply::sslErrors() is not emitted at all (neither the first time nor the subsequent)

    Also, some Qt module writes the string "qt.network.ssl: QSslSocket::connectToHostEncrypted: TLS initialization failed" to the Application Output after each request.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,734
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QNetworkAccessManager finished() isn't emitted after the 2nd request when SSL err

    This could be reusing the failed connection from a cache rather than establishing a new one, thereby exercising a different code path.
    Does the behaviour change if you call QNetworkAccessManager::clearConnectionCache() between gets?

    When I have the Qt source code to hand I will have a look for the specific situation.

  5. #5
    Join Date
    Apr 2020
    Posts
    3
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QNetworkAccessManager finished() isn't emitted after the 2nd request when SSL err

    Quote Originally Posted by ChrisW67 View Post
    Does the behaviour change if you call QNetworkAccessManager::clearConnectionCache() between gets?
    Yes, thank you, it helps. Making clearConnectionCache() before each request solves the problem - finished() signal is emitted every time.

    But I am doubtful, will using this method spoil the keep-alive connections?

Similar Threads

  1. QNetworkAccessManager no finished() signal emitted
    By realperson in forum Qt Programming
    Replies: 4
    Last Post: 18th January 2018, 08:42
  2. Replies: 2
    Last Post: 9th March 2017, 13:36
  3. QNetworkAccessManager - finished signal (when emitted)
    By RavensAngel in forum Qt Programming
    Replies: 4
    Last Post: 16th March 2016, 20:46
  4. Replies: 8
    Last Post: 12th January 2015, 22:08
  5. QNetworkAccessManager Finished() Error
    By ttimt in forum Newbie
    Replies: 10
    Last Post: 25th February 2014, 13:21

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.