[Interest] QWebSocketServer on iOS

Mårten Nordheim marten.nordheim at qt.io
Tue Mar 29 11:30:39 CEST 2022


Hey Alex,

Unfortunately I don't think there's a way around it as it's a security measure (though I could be wrong).
It simply disallows establishing insecure connections from secure sources.

Mårten.

________________________________________
From: Interest <interest-bounces at qt-project.org> on behalf of Alexander Carôt <alexander_carot at gmx.net>
Sent: Tuesday, March 29, 2022 09:37
To: qt qt
Subject: Re: [Interest] QWebSocketServer on iOS

>> Can you confirm and possibly resolve ?

I just created a secure websocket on localhost and it connected fine. Looks like iOS does not permit non-secure websockets on secure websites at all (on OSX this works except for Safari). If there is another workaround please let me know.

Best

Alex


--
http://www.carot.de
Email : Alexander at Carot.de
Tel.: +49 (0)177 5719797


> Gesendet: Montag, 28. März 2022 um 19:41 Uhr
> Von: "Alexander Carôt" <alexander_carot at gmx.net>
> An: "Mårten Nordheim" <marten.nordheim at qt.io>
> Cc: "qt qt" <interest at qt-project.org>
> Betreff: Re: [Interest] QWebSocketServer on iOS
>
> Hej Marten,
>
> Here we go – please find the sample code regarding the iOS websocket issue here:
>
> https://www.dropbox.com/s/y7nr3ywht75exhw/iOS_audio.zip?dl=0
>
> This one does not contain the webbrowser yet it can be used with any iOS browser (Safari, Chrome, FF etc.) with the following script:
>
> http://carot.de
>
> If successful it shows "SJC connected – version 211105".
>
> I think I already figured when it fails: If the script runs on an ssl encypted site it does not connect – on OSX this only happens with Safari but on iOS this might be a general networking restriction. Here is the same script on a secure website:
>
> https://soundjack.eu/ws
>
> Can you confirm and possibly resolve ?
>
> Thanks and best
>
> Alex
>
> --
> http://www.carot.de
> Email : Alexander at Carot.de
> Tel.: +49 (0)177 5719797
>
>
> > Gesendet: Montag, 28. März 2022 um 10:02 Uhr
> > Von: "Mårten Nordheim" <marten.nordheim at qt.io>
> > An: "Alexander Carôt" <alexander_carot at gmx.net>, "qt qt" <interest at qt-project.org>
> > Betreff: Re: Re: Re: [Interest] QWebSocketServer on iOS
> >
> > Is there anything printed out in the console of the browser?
> > And it shouldn't be needed, but you can try connecting to the
> > originAuthenticationRequired signal:
> > https://doc.qt.io/qt-5/qwebsocketserver.html#originAuthenticationRequired
> > In case that's where it somehow goes wrong.
> >
> > Mårten
> >
> > ________________________________________
> > From: Alexander Carôt <alexander_carot at gmx.net>
> > Sent: Friday, March 25, 2022 20:39
> > To: Mårten Nordheim; qt qt
> > Subject: Aw: Re: Re: [Interest] QWebSocketServer on iOS
> >
> > Hej Marten,
> >
> > >> Just on the off-chance that it makes a difference - have you tried using ws://localhost instead of 127.0.0.1?
> >
> > Just did it a few hours ago and it made no difference.
> >
> > >> If not, do you have a minimal reproducer that can be shared (with/without the qml browser)?
> >
> > I will send over sample code which includes the problematic sources in the most illustrative way soon.
> >
> > Meantime here more insights to the issue:
> >
> > I reconfigured the websocket server to 0.0.0.0 – then I can connect from the same LAN from a different machine via a script that contains ws://192.168.0.56:50050, however, I cannot connect from an external Domain myDomain.de/connectScript.html (the same script and call above is triggered on the same machine in the same LAN, however, now retrieved from a remote server). Neither I can connect from the iOS app-own browser via localhost either. Furthermore, please forget about the crash which occurs for other implementational reasons.
> >
> > Will get back with sample code,
> > best
> >
> > Alex
> >
> >
> > --
> > http://www.carot.de
> > Email : Alexander at Carot.de
> > Tel.: +49 (0)177 5719797
> >
> >
> > > Gesendet: Freitag, 25. März 2022 um 11:54 Uhr
> > > Von: "Mårten Nordheim" <marten.nordheim at qt.io>
> > > An: "Alexander Carôt" <alexander_carot at gmx.net>, "qt qt" <interest at qt-project.org>
> > > Betreff: Re: Re: [Interest] QWebSocketServer on iOS
> > >
> > > Hey again,
> > >
> > > Just on the off-chance that it makes a difference - have you tried using ws://localhost instead of 127.0.0.1?
> > > If not, do you have a minimal reproducer that can be shared (with/without the qml browser)?
> > >
> > > Mårten.
> > >
> > > ________________________________________
> > > From: Alexander Carôt <alexander_carot at gmx.net>
> > > Sent: Thursday, March 24, 2022 17:51
> > > To: Mårten Nordheim; qt qt
> > > Subject: Aw: Re: [Interest] QWebSocketServer on iOS
> > >
> > > Hej Marten and all,
> > >
> > > >>though on mobile devices you may be subject to your application
> > > >> being put to sleep when it goes into the background.
> > >
> > > Meantime this is what I ran into which is why I eventually bundled the qml minibrowser and my application. The browser tries to connect to the application via ws://127.0.0.1:50050 and this works out well on macOS. On iOS, however, the connection fails and, furthermore, any other action (e.g. sending packets) with the websocket server endpoint makes the app crash. Hence, I'd suspect this is due to iOS specific security settings – also because the dialog to allow local network usage does not show up. Please find here the list of network related security keys I applied in the Info.plist file
> > >
> > > <key>NSLocalNetworkUsageDescription</key>
> > > <string>Uses local networking to communicate settings…</string>
> > > <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key><true/>
> > >
> > > <key>NSAppTransportSecurity</key>
> > >        <dict>
> > >                 <key>NSAllowsArbitraryLoads</key><true/>
> > >                 <key>NSAllowsArbitraryLoadsForMedia</key><true/>
> > >                 <key>NSAllowsArbitraryLoadsInWebContent</key><true/>
> > >                 <key>NSAllowsLocalNetworking</key><true/>
> > >                 <key>NSExceptionDomains</key>
> > >                 <dict>
> > >                         <key>localhost</key>
> > >                         <dict>
> > >                                 <key>NSExceptionAllowsInsecureHTTPLoads</key><true/>
> > >                                 <key>NSIncludesSubdomains</key><true/>
> > >                         </dict>
> > >                         <key>mydomain.com</key>
> > >                         <dict>
> > >                                 <key>NSExceptionAllowsInsecureHTTPLoads</key><true/>
> > >                                 <key>NSIncludesSubdomains</key><true/>
> > >                         </dict>
> > >                 </dict>
> > >         </dict>
> > >
> > > Am I missing anything in terms of security keys or does anyone have a different suggestions how to resolve this issue ?
> > >
> > > Best
> > >
> > > Alex
> > >
> > > P.S.: Thiago: No firewalls installed and the websocket is running on localhost.
> > >
> > >
> > > --
> > > http://www.carot.de
> > > Email : Alexander at Carot.de
> > > Tel.: +49 (0)177 5719797
> > >
> > >
> > > > Gesendet: Dienstag, 22. März 2022 um 12:43 Uhr
> > > > Von: "Mårten Nordheim" <marten.nordheim at qt.io>
> > > > An: "Alexander Carôt" <alexander_carot at gmx.net>, "qt qt" <interest at qt-project.org>
> > > > Betreff: Re: [Interest] QWebSocketServer on iOS
> > > >
> > > > Hello Alex,
> > > >
> > > > There's no reason why listening to a port on iOS shouldn't work, though on mobile devices you may be subject to your application
> > > > being put to sleep when it goes into the background.
> > > >
> > > > Mårten.
> > > >
> > > > ________________________________________
> > > > From: Interest <interest-bounces at qt-project.org> on behalf of Alexander Carôt <alexander_carot at gmx.net>
> > > > Sent: Monday, March 21, 2022 10:24
> > > > To: qt qt
> > > > Subject: [Interest] QWebSocketServer on iOS
> > > >
> > > > Hi all,
> > > >
> > > > I have an application running a QWebSocketServer::NonSecureMode on localhost and I am using a web browser to connect. This works fine on OSX, Linux and Windows so far.
> > > >
> > > > However, I just ported the app to iOS and here it has so far not been possible to establish a connection yet.
> > > >
> > > > Before I dig deeper in terms of debugging I wonder if probably this not supported for iOS at all ?
> > > >
> > > > So far I did not see any error message, however.
> > > >
> > > > Thanks in advance for pointers of any kind.
> > > >
> > > > Best
> > > >
> > > > Alex
> > > >
> > > > --
> > > > http://www.carot.de
> > > > Email : Alexander at Carot.de
> > > > Tel.: +49 (0)177 5719797
> > > >
> > > > _______________________________________________
> > > > Interest mailing list
> > > > Interest at qt-project.org
> > > > https://lists.qt-project.org/listinfo/interest
> > > >
> > >
> >
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> https://lists.qt-project.org/listinfo/interest
>
_______________________________________________
Interest mailing list
Interest at qt-project.org
https://lists.qt-project.org/listinfo/interest


More information about the Interest mailing list