×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Apr 2004
    Posts
    14

    QNetworkAcessManager and network connectivity state changes

    Hi All,

    I've been trying to write an app that does some basic web processing, and I'm using the QNetworkAccessManager. It's all working well, but when a connection changes, the QNAM drops it's bundle, and returns 'host not found'. I can replicate with a simple app as such:

    void MainWindow:n_pushButton_clicked()
    {
    _manager = new QNetworkAccessManager(this);
    QUrl url("http://www.google.com/");
    _reply = _manager->get(QNetworkRequest(url));
    connect(_reply, SIGNAL(finished()), this, SLOT(reply_finished()));
    }

    void MainWindow::reply_finished()
    {
    QString data = _reply->readAll();
    qDebug() << "Data: " << data;

    qDebug() << "Error: " << _reply->errorString();

    _reply->deleteLater();
    _reply = NULL;

    _manager->deleteLater();
    _manager = NULL;
    }


    When I run this app, it works fine at first, connects up the first time I push the button, and shows the expected data. Then I went to connections on the n8, and disconnected the WLAn access point. Then I switched back to the app and tried pressing the button again, and the error was 'host not found'. Then I went to connection manager and reconnected the WLan manually, and still the button gave 'host not found'.

    Is this expected, and is there some explicit call that needs to be used to allow the QNAM to change connections?

    TIA -Mike

  2. #2
    Registered User
    Join Date
    Aug 2006
    Posts
    182

    Re: QNetworkAcessManager and network connectivity state changes

    You need to implement the Session manager which will be notified for the session disconnected. Try to open the session using QNetworkConfigurationManager before sending any request. This way you can make the applicatino more reliable and error prone.

    refer this:
    http://wiki.forum.nokia.com/index.ph...nnection_in_Qt

    And register for the notification using slot signal mechanism.
    PS: Before posting do try wiki search to save your time and effort:
    http://wiki.forum.nokia.com/index.php/Wiki_Home

  3. #3
    Registered User
    Join Date
    Apr 2004
    Posts
    14

    Re: QNetworkAcessManager and network connectivity state changes

    Thanks for the reply, I have tried using the Bearer API stuff, and that didn't seem to help, although it would reconnect when the wlan came back, but it wouldn't roam onto 3g. I saw the 'preferred' AP change, but the session didn't seem to. I'll put together a nuts and bolts sample soon to show how I'm using the QNetworkConfigurationManager, it could just be that I'm 'holding it wrong' :P

  4. #4
    Registered User
    Join Date
    Apr 2004
    Posts
    14

    Re: QNetworkAcessManager and network connectivity state changes

    Have found that I need to close the current NetworkSession whenever it roams and open a new one, as although the netsession state goes back to connected after roaming, until it is killed and recreated, the networkaccessmanager keeps giving 'host not found'. So basically I'm looking out for the Error on the network session, and the 'preferred config changed' event as well, and if either happen, disconnecting and reconnecting. From reading the docs, it looks like i should just be able to call 'accept' in the net session on the 'preferred config changed' signal, but that didn't work for me. Again, I only tried on an N8.

    Thanks for the kick in the right direction -Mike

Similar Threads

  1. Changing Icon State on MWS Connectivity
    By ARJWright in forum Mobile Web Server
    Replies: 1
    Last Post: 2009-11-25, 14:08
  2. Monitoring voice call state network layer
    By stenlik in forum Symbian Networking & Messaging (Closed)
    Replies: 0
    Last Post: 2009-11-23, 13:35
  3. Network connectivity
    By danieb_za in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2008-06-25, 07:51
  4. Connectivity to Network when using MTM
    By niko.gunadi in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2007-08-20, 05:22
  5. Network Connectivity
    By Mad-Marty in forum Symbian
    Replies: 0
    Last Post: 2006-02-09, 21:58

Posting Permissions

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