×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    8

    [Resolved] My netwok connection always return error in 3G but works fine in wireless

    Hi,

    I am testing a simple application in QT 4.6. It is working fine in Wifi or in simulator, but I allways have a "202 error : QNetworkReply::ContentOperationNotPermittedError" in 3G mode on the phone (N97 mini).

    Here is my sample code :

    Code:
    void Soce::on_okLoginButton_clicked()
    {
        QNetworkAccessManager* manager = new QNetworkAccessManager(this);
    
        QUrl url("http://www.google.fr");
        QNetworkRequest request;
        request.setUrl(url);
        
        connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(nameRetrived(QNetworkReply*)));
        QNetworkReply* reply = manager->get(request);
    
    }
    
    void Soce::nameRetrived(QNetworkReply* reply)
    {
     
        if(reply->error() == QNetworkReply::NoError)
        {
           ...
        }
        else
        {
            l_titre->setText("Error : " + QString::number(reply->error()));
        }
    
        reply->deleteLater();
    
    }
    Gives "Error : 202" in 3g or Edge.
    Last edited by remi.vanel; 2011-04-29 at 15:32. Reason: Resolved

  2. #2
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Location
    Finland
    Posts
    327

    Re: My netwok connection always return 202 error in 3G but works fine in wireless

    Just checking, do you have CAPABILITIES += NetworkServices in your symbian target ?

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    8

    Re: My netwok connection always return 202 error in 3G but works fine in wireless

    Yes I have this capability. Thanks

    My .pro :
    Code:
    QT       += core gui network
    
    
    TARGET = Soce
    TEMPLATE = app
    
    SOURCES += main.cpp\
            soce.cpp
    
    HEADERS  += soce.h
    
    FORMS    += soce.ui
    
    CONFIG += mobility
    MOBILITY =
    
    symbian {
        TARGET.UID3 = 0xeb5c0342
        TARGET.CAPABILITY += NetworkServices
        TARGET.EPOCSTACKSIZE = 0x14000
        TARGET.EPOCHEAPSIZE = 0x020000 0x800000
    }

  4. #4
    Nokia Developer Moderator
    Join Date
    Oct 2009
    Location
    Finland
    Posts
    327

    Re: My netwok connection always return 202 error in 3G but works fine in wireless

    Hm, 202 error in a HTTP request is either a HTTP 403 (Access Denied) or a 405 (Method Not Allowed). Which is kind of weird if you want to get a google search page. Can you try to drop a QWebView in your app just to see what is 'really' shown to the device ?

    PS. Try to use a single QNetworkAccessManager for the whole application, creating one every time you press a button can cause problems.

  5. #5
    Registered User
    Join Date
    Oct 2010
    Posts
    8

    Re: My netwok connection always return 202 error in 3G but works fine in wireless

    Thanks for your help.
    The QWebView works great with exactly the same url !
    I just add this line :
    Code:
    ui->webView->setUrl(url);
    But I still have the 202 error for the QNetworkReply.
    Moving the QNetworkAccessManager in the "Soce::Soce(QWidget *parent)" doesn't change anything...

  6. #6
    Registered User
    Join Date
    Oct 2010
    Posts
    8

    Re: My netwok connection always return 202 error in 3G but works fine in wireless

    no one to help me ?

  7. #7
    Registered User
    Join Date
    Jun 2007
    Location
    Mumbai, India
    Posts
    1,998

    Re: My netwok connection always return 202 error in 3G but works fine in wireless

    HTTP 202 means OK; accepted for processing, but processing is not completed.

    Can you try with some other url and check once.

  8. #8
    Registered User
    Join Date
    Oct 2010
    Posts
    8

    Re: My netwok connection always return 202 error in 3G but works fine in wireless

    I tried with many URL with the same result.

    For information, the 202 code is the QNetworkReply response code, not the HTTP Status code.
    If I ignore this error, I have 403 HTTP error while trying to get reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toUInt().

    One more time : I only have this issue in 3G, it is working fine in Wifi or in simulator.

    Thanks for your help

    the last code used :

    Code:
    void Soce::on_okLoginButton_clicked()
    {
    
        QUrl url("http://www.nokia.com/landing-page/selected_country");
    
        ui->webView->setUrl(url);
    
        QNetworkRequest request;
        request.setUrl(url);
    
        reply = manager->get(request);
    
        connect(reply, SIGNAL(finished()), this, SLOT(nameRetrived()));
    
        l_titre->setText("Getting name for " + e_login->toPlainText());
    
    }
    
    void Soce::nameRetrived()
    {
        QString replyString;
        QStringList groupString;
    
        if(reply->error() == QNetworkReply::NoError)       ////    THE ISSUE IS HERE
        {
            int httpstatuscode = reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toUInt();
            if(httpstatuscode >=200 && httpstatuscode < 300)
            {
                if (reply->isReadable())
                {
                    ........
                }
                else
                {
                    replyString = "Ok but non readable";
                }
            }
            if(httpstatuscode >= 300 && httpstatuscode<400)
            {
                replyString = "3xx Redirection";
            }
            if(httpstatuscode >= 400 && httpstatuscode<500)
            {
                replyString = "4xx Error";
            }
            l_titre->setText(QString::number(httpstatuscode) + " return " + replyString);
    
        }
        else
        {
            l_titre->setText("Error : " + QString::number(reply->error()));
            ui->liste->clear();
            ui->liste->addItem("Ne peut pas récupérer la liste");
        }
    
        reply->deleteLater();
    
    }

  9. #9
    remy_david
    Guest

    Re: My netwok connection always return 202 error in 3G but works fine in wireless

    Hello,

    I have exactly the same problem. I am using SDK 1.1 and Nokia N8.
    Works fine in simulator and Wifi, but I have the same error in 3G.
    Capabilities are set and same urls work in phone browser/QWebView.
    I tried both with signed and unsigned.
    Last edited by remy_david; 2011-04-28 at 18:56.

  10. #10
    remy_david
    Guest

    Re: My netwok connection always return 202 error in 3G but works fine in wireless

    I changed my SIM for another carrier and now it works.
    I am in France, SFR is giving me 202 while it works fine with Orange.
    Problem was default QNetworkRequest has an empty user agent, that my carrier proxy was blocking.
    Solution:
    .h
    Code:
    #include <QWebPage>
    
    class UserAgentProvider : public QWebPage
    {
        Q_OBJECT
    public:
        explicit UserAgentProvider(QObject *parent = 0);
        QString getUserAgent();
    };
    .cpp
    Code:
    #include "useragentprovider.h"
    
    UserAgentProvider::UserAgentProvider(QObject *parent) :
        QWebPage(parent)
    {
    }
    
    QString UserAgentProvider::getUserAgent()
    {
        return userAgentForUrl(QUrl(""));
    }
    Code:
    UserAgentProvider p;
    userAgent = p.getUserAgent();
    QNetworkRequest request(url);
    request.setRawHeader("User-Agent",userAgent.toAscii());
    Last edited by remy_david; 2011-04-29 at 12:37.

  11. #11
    Registered User
    Join Date
    Oct 2010
    Posts
    8

    Re: My netwok connection always return 202 error in 3G but works fine in wireless

    !!! OK I understand, I'm in the same case !
    Thanks SFR.....

    But I don't understand why my other N97 apps works, they aren't in QT

  12. #12
    Registered User
    Join Date
    Oct 2010
    Posts
    8

    Re: My netwok connection always return 202 error in 3G but works fine in wireless

    Génial, ça marche, enfin ! Merci.

    Many Thanks !
    It works.

    Issue resolved

Similar Threads

  1. Replies: 1
    Last Post: 2010-06-13, 17:37
  2. Replies: 3
    Last Post: 2010-03-17, 19:36
  3. Game Does not Launch in 3200, but works fine in all other compats
    By Sudhalucky in forum Mobile Java General
    Replies: 1
    Last Post: 2007-12-13, 10:51

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×