[Interest] QWebSocketServer on iOS

Mårten Nordheim marten.nordheim at qt.io
Fri Mar 25 11:54:54 CET 2022


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
>


More information about the Interest mailing list