Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. QWebView displays "Network Access is disabled" and Qt Network Error 99
Forum Updated to NodeBB v4.3 + New Features

QWebView displays "Network Access is disabled" and Qt Network Error 99

Scheduled Pinned Locked Moved Unsolved Qt WebKit
5 Posts 2 Posters 919 Views 1 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
    anshah
    wrote on 18 Jan 2024, 03:27 last edited by anshah
    #1

    Running with:

    • Ubuntu 22.04.

    • Qt 5.12.8

    • OpenSSL 1.1.1f 31

    QWebView is showing this error:
    Screenshot 2024-01-17 at 9.28.49 AM.jpg

    This Url works with no issues in the Firefox browser but QWebView seems to have an issue.

    Here's the QNetworkReply info from the logs:

    Failed URL: "https://dev-81029421.okta.com/app/dev-81029421_442710740samlidp_1/exkanm3x81DrxatKc5d7/sso/saml"
    
    NetworkError: QNetworkReply::UnknownNetworkError
    http status = 0
    httpStatusMsg = ""
    

    Here is my QWebView setup. I double checked everything and it looks correct. Not sure what to try next:

    QWebView * m_samlView = new QWebView();
    
    // Set User Agent
    QString browserUserAgent = m_samlView->page()->mainFrame()->evaluateJavaScript("navigator.userAgent").toString();
    m_pUserAgentPage = new UserAgentWebPage();
    m_pUserAgentPage->setBrowserUserAgent(browserUserAgent);
    m_samlView->setPage(m_pUserAgentPage);
    
    // Network Access Manager
    m_pNetworkAccessManager = new QNetworkAccessManager();
    m_pNetworkAccessManager->setNetworkAccessible(QNetworkAccessManager::Accessible);
    m_samlView->page()->setNetworkAccessManager(m_pNetworkAccessManager);
    
    // Network Proxy
    checkProxy(); 
    QNetworkProxy::setApplicationProxy(m_networkProxy);
    m_samlView->page()->networkAccessManager()->setProxy(m_networkProxy);
    
    // Enable Javascript
    m_samlView->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
    
     // Enable web inspector
    m_samlView->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
    
    QWebInspector inspector;
    inspector.setPage(m_samlView->page());
    inspector.setVisible(true);
    
    // Setup Network Cookie Jar
    m_pCookieJar = new CookieJar();
    m_samlView->page()->networkAccessManager()->setCookieJar(m_pCookieJar);
    
    // Clear cache and cookies
    clearCacheAndCookies();
    
    // QWebView: Connect signals/slots
    connect(m_samlView, SIGNAL(urlChanged(const QUrl&)),
            this,       SLOT(onUrlChanged(const QUrl&)));
    connect(m_samlView, SIGNAL(loadFinished(bool)),
            this,       SLOT(onLoadFinished(bool)));
    
    // QNetworkAccessManager: Connect signals/slots
    connect(m_pNetworkAccessManager, SIGNAL(finished(QNetworkReply*)),
            this,                    SLOT(onFinished(QNetworkReply*)));
    connect(m_pNetworkAccessManager, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)),
            this,                    SLOT(onSslErrors(QNetworkReply*, const QList<QSslError>&)));
    

    The web page in question is an Okta SAML Authentication page coming from a Gateway that is behind an Network Load Balancer. Not sure if this is affects the QNetworkReply error.

    A 1 Reply Last reply 18 Jan 2024, 07:18
    0
    • A anshah
      18 Jan 2024, 03:27

      Running with:

      • Ubuntu 22.04.

      • Qt 5.12.8

      • OpenSSL 1.1.1f 31

      QWebView is showing this error:
      Screenshot 2024-01-17 at 9.28.49 AM.jpg

      This Url works with no issues in the Firefox browser but QWebView seems to have an issue.

      Here's the QNetworkReply info from the logs:

      Failed URL: "https://dev-81029421.okta.com/app/dev-81029421_442710740samlidp_1/exkanm3x81DrxatKc5d7/sso/saml"
      
      NetworkError: QNetworkReply::UnknownNetworkError
      http status = 0
      httpStatusMsg = ""
      

      Here is my QWebView setup. I double checked everything and it looks correct. Not sure what to try next:

      QWebView * m_samlView = new QWebView();
      
      // Set User Agent
      QString browserUserAgent = m_samlView->page()->mainFrame()->evaluateJavaScript("navigator.userAgent").toString();
      m_pUserAgentPage = new UserAgentWebPage();
      m_pUserAgentPage->setBrowserUserAgent(browserUserAgent);
      m_samlView->setPage(m_pUserAgentPage);
      
      // Network Access Manager
      m_pNetworkAccessManager = new QNetworkAccessManager();
      m_pNetworkAccessManager->setNetworkAccessible(QNetworkAccessManager::Accessible);
      m_samlView->page()->setNetworkAccessManager(m_pNetworkAccessManager);
      
      // Network Proxy
      checkProxy(); 
      QNetworkProxy::setApplicationProxy(m_networkProxy);
      m_samlView->page()->networkAccessManager()->setProxy(m_networkProxy);
      
      // Enable Javascript
      m_samlView->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
      
       // Enable web inspector
      m_samlView->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
      
      QWebInspector inspector;
      inspector.setPage(m_samlView->page());
      inspector.setVisible(true);
      
      // Setup Network Cookie Jar
      m_pCookieJar = new CookieJar();
      m_samlView->page()->networkAccessManager()->setCookieJar(m_pCookieJar);
      
      // Clear cache and cookies
      clearCacheAndCookies();
      
      // QWebView: Connect signals/slots
      connect(m_samlView, SIGNAL(urlChanged(const QUrl&)),
              this,       SLOT(onUrlChanged(const QUrl&)));
      connect(m_samlView, SIGNAL(loadFinished(bool)),
              this,       SLOT(onLoadFinished(bool)));
      
      // QNetworkAccessManager: Connect signals/slots
      connect(m_pNetworkAccessManager, SIGNAL(finished(QNetworkReply*)),
              this,                    SLOT(onFinished(QNetworkReply*)));
      connect(m_pNetworkAccessManager, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)),
              this,                    SLOT(onSslErrors(QNetworkReply*, const QList<QSslError>&)));
      

      The web page in question is an Okta SAML Authentication page coming from a Gateway that is behind an Network Load Balancer. Not sure if this is affects the QNetworkReply error.

      A Offline
      A Offline
      anshah
      wrote on 18 Jan 2024, 07:18 last edited by
      #2

      Hello @SGaist

      I saw you suggested someone to reinitialize NAM as in this forum post:

      https://forum.qt.io/topic/136305/qt-c-application-results-qnetworkreply-unknownnetworkerror-error-after-network-restart/4

      Would that work in my case here?

      S 1 Reply Last reply 18 Jan 2024, 22:18
      0
      • A anshah
        18 Jan 2024, 07:18

        Hello @SGaist

        I saw you suggested someone to reinitialize NAM as in this forum post:

        https://forum.qt.io/topic/136305/qt-c-application-results-qnetworkreply-unknownnetworkerror-error-after-network-restart/4

        Would that work in my case here?

        S Offline
        S Offline
        SGaist
        Lifetime Qt Champion
        wrote on 18 Jan 2024, 22:18 last edited by
        #3

        Hi,

        Since you have a proxy, did you also connect the other QNAM signals related to authentication ?

        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 18 Jan 2024, 23:40
        0
        • S SGaist
          18 Jan 2024, 22:18

          Hi,

          Since you have a proxy, did you also connect the other QNAM signals related to authentication ?

          A Offline
          A Offline
          anshah
          wrote on 18 Jan 2024, 23:40 last edited by anshah
          #4

          @SGaist Thank you for replying.

          Currently the only QNAM signals connected are as follows:

          // QNetworkAccessManager: Connect signals/slots
          connect(m_pNetworkAccessManager, SIGNAL(finished(QNetworkReply*)),
                  this,                    SLOT(onFinished(QNetworkReply*)));
          connect(m_pNetworkAccessManager, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)),
                  this,                    SLOT(onSslErrors(QNetworkReply*, const QList<QSslError>&)));
          

          In this particular test case, we did not have proxy setup but you are right it may be a good idea to connect the QNAM auth signals in case we do. Which signals were you thinking of? Do you think that contributed to the crash?

          S 1 Reply Last reply 19 Jan 2024, 20:37
          0
          • A anshah
            18 Jan 2024, 23:40

            @SGaist Thank you for replying.

            Currently the only QNAM signals connected are as follows:

            // QNetworkAccessManager: Connect signals/slots
            connect(m_pNetworkAccessManager, SIGNAL(finished(QNetworkReply*)),
                    this,                    SLOT(onFinished(QNetworkReply*)));
            connect(m_pNetworkAccessManager, SIGNAL(sslErrors(QNetworkReply*, const QList<QSslError>&)),
                    this,                    SLOT(onSslErrors(QNetworkReply*, const QList<QSslError>&)));
            

            In this particular test case, we did not have proxy setup but you are right it may be a good idea to connect the QNAM auth signals in case we do. Which signals were you thinking of? Do you think that contributed to the crash?

            S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 19 Jan 2024, 20:37 last edited by
            #5

            @anshah all the ones listed under the Signals part of the class documentation.

            Crash ? I thought you only had an error.

            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
            0

            4/5

            18 Jan 2024, 23:40

            • Login

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