[SailfishDevel] QNetworkAccessManager is losing connection upon switching between wifi and mobile

Alexander Ladygin fake.ae at gmail.com
Wed Nov 11 13:20:11 UTC 2015


Hei Lorn

I probably didn't make myself clear =(
1) wifi is turned on
2) app is launched, i can download files with QNAM
3) app is still launched, i turn off the wifi (mobile network activated)
4) i can no longer download any files. No network errors, but QNAM's reply
returns empty files
5) turn the wifi back on - i can download files

When wifi is turned off, i've tried:
1) creating new instance: _pManager = new QNetworkAccessManager(this);
2) clearing access cache: _pManager->clearAccessCache();
3) updating network configuration: _configManager.updateConfigurations()
and then

QList<QNetworkConfiguration> activeConfigs =
_configManager.allConfigurations(QNetworkConfiguration::Active);
if (activeConfigs.count() > 0) {
    _pManager->setConfiguration(activeConfigs.at(0));
    qDebug() << "QNetworkConfiguration = " << activeConfigs.at(0).name();
}
In that case qDebug shows that active configuration is, indeed, mobile
network

But nothing helped. Only restarting app helps

Maybe you can look at sources, if you have couple of spare minutes
https://github.com/virgi26/harbour-vk-music/blob/master/src/downloadmanager.cpp
Thank you for your time.

Alex.


On Wed, Nov 11, 2015 at 1:13 PM, Lorn Potter <lorn.potter at jolla.com> wrote:

>
> > On 11 Nov 2015, at 8:09 pm, Lorn Potter <lorn.potter at jolla.com> wrote:
> >
> > Hi Alex,
> >
> > Having tested this, it does seem to be a bug in that when connecting to
> wlan
>
> I should have specified here when already connected to mobile data and
> then connecting to wlan without first disconnecting mobile data.
>
>
> > , QNAM’s networkAccessibility sometimes will go to NotAccessible, but
> then go to Accessible when wlan connects. or sometimes it won’t even go to
> NotAccessible then Accessible when wlan is connected.
> >
> > You should be able to track QNAM through its networkAccessibilty
> property. it should follow the online state, unless you specifically set it
> to NotAccessible.
> >
> > QNAM uses QNetworkConfiguration internally, and it should automatically
> switch this to the current Active configuration.
> >
> >
> > -
> > Lorn
> >
> >> On 10 Nov 2015, at 10:37 am, Alexander Ladygin <fake.ae at gmail.com>
> wrote:
> >>
> >> Hey!
> >>
> >> I've got an issue: QNetworkAccessManager is losing connection upon
> switching between wifi and mobile:( What exactly should i do/update to make
> it work properly? Maybe need to change network configuration? Why it is not
> handled by platform?
> >> Thanks.
> >>
> >> Alex
> >> _______________________________________________
> >> SailfishOS.org Devel mailing list
> >> To unsubscribe, please send a mail to
> devel-unsubscribe at lists.sailfishos.org
> >
>
> _______________________________________________
> SailfishOS.org Devel mailing list
> To unsubscribe, please send a mail to
> devel-unsubscribe at lists.sailfishos.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.sailfishos.org/pipermail/devel/attachments/20151111/dd444bad/attachment.html>


More information about the Devel mailing list