Issue with local network http stream on iOS when Cell Data permissions allowed?
Posted: 30 Aug 2024 07:49
I am trying to stream a mp4 video file from a local network device. The WiFi network through which is hosted by a dashcam! I am getting http connection issues from MobileVLCKit on iOS, and have narrowed down the root cause to the media get request, and network setup.
Essentially when using MobileVLCKit to try and consume a http stream from a WiFi network with no internet access, VLC will send the request to my 192.168.1.254 host through cellular data, not WiFi. If I disable cellular data permissions for that app in iOS settings, the stream works correctly.
Have sniffed packet dumps with wireshark, the VLC request never goes to local network device if cellular available and device does not have access to internet through WiFi network. The only instance I have seen where it does, is after 3 failed attempts, and it changes request protocol from HTTP 1.1 to HTTP 1.0 and then the stream fails anyway.
I need to keep cellular data permissions on in my app because my users likely use that in other flows, and then can share content directly from their dashcams when they review it for the first time. I think VLC seems to just handle the media url wrong with the network setup, though maybe there is something else I could be doing? Afaik I cannot configure the app to programmatically preference local network over cellular data when it has no internet access, so in my opinion it's probably a VLC problem, not a me problem. Please change my mind! When I use AVPlayer, it correctly handles the http stream, so that's another reason I think VLC is just resolving the address wrong.
I haven't done much testing with Android at all yet, but seems to experience the same issue (when tested with the VLC app itself).
Have reproduced this bug on several iPhones and one Android phone so far.
Operating system: iOS 17.6.1 (and several more iOS versions including iOS 18 betas and iOS 17 RCs)
VLC media player version: MobileVLCKit 3.6.0 (VLC/3.0.21)
Hardware: iPhone 15 Pro Max, iPhone 15 Pro, iPhone 14 Pro Max, iPhone 13 Pro Max, iPhone XS Max, Pixel 6
Steps to reproduce:
1. Host a WiFi network with no internet access, connect your iPhone and some other device with which you can host a http stream using VLC.***
2. On that WiFi network, use a computer to host a http local network stream at an address starting with 192.168. I used an mp4 file (mp4a and H.264)
3. Open the VLC app on your iPhone and try to consume the http stream. The stream will not load. ^^^
4. Open settings on your iPhone, navigate to VLC settings and disable cellular data.
5. Return to VLC and consume your stream. It will play, beca
*** WiFi setup sounds tricky, here is what I did; I restricted my iPhone's ability to access the internet on my WiFi network through a router rule. I then hosted a http stream with an mp4 file on vlc using a MacBook Pro on the same WiFi network using this call:
vlc -vvvv ~/Desktop/CYQ_0107.MP4 --sout #'standard{access=http,mux=ts,dst=:80/CYQ_0107.MP4}'
^^^ If you use router rules to restrict network access, you may need to wait until your phone throws an error saying there is no internet access via the WiFi network, and allow cellular data use. I needed to do that, the http stream works normally until your phone realises that the WiFi network has no internet access.
Reproducibility:
On iOS 100% of streams from host on 192.168.x.x available on local network when WiFi has no internet access and device has cell data available.
On Android 100% of http streams from host on 192.168.x.x on available on local network when WiFi has no internet access and device has cell data available.
On MacOS VLC from CLI will consume the http stream correctly, even when it can access a network on ethernet with internet, and WiFi is connected to a seperate network with no internet access.
File type:
mp4, codecs MPEG4-AAC and h.264. No subs
Issue is not file specific, is related to stream setup, but happy to provide files.
Have attached verbose logging from VLC in the cases where the stream fails due to cell data being available, and the case where cell data is not available and it works. I also have a screen recording if you'd rather watch that to understand.
cell data permission allowed: https://pastebin.com/5RDQYSBQ
cell data permission not allowed: https://pastebin.com/gzRYQApz
This problem has had me stumped for a while, until I started network logging, and then I saw what was happening pretty quickly! If anyone has ideas on how to work around this in an iOS app (and it seems like I'll need to do that in Android too) please let me know, otherwise I guess I might have to just start compiling MobileVLCKit from source and tracing the issue further up the chain to try and resolve it myself, but I'd really like to not have to do that! lol
Essentially when using MobileVLCKit to try and consume a http stream from a WiFi network with no internet access, VLC will send the request to my 192.168.1.254 host through cellular data, not WiFi. If I disable cellular data permissions for that app in iOS settings, the stream works correctly.
Have sniffed packet dumps with wireshark, the VLC request never goes to local network device if cellular available and device does not have access to internet through WiFi network. The only instance I have seen where it does, is after 3 failed attempts, and it changes request protocol from HTTP 1.1 to HTTP 1.0 and then the stream fails anyway.
I need to keep cellular data permissions on in my app because my users likely use that in other flows, and then can share content directly from their dashcams when they review it for the first time. I think VLC seems to just handle the media url wrong with the network setup, though maybe there is something else I could be doing? Afaik I cannot configure the app to programmatically preference local network over cellular data when it has no internet access, so in my opinion it's probably a VLC problem, not a me problem. Please change my mind! When I use AVPlayer, it correctly handles the http stream, so that's another reason I think VLC is just resolving the address wrong.
I haven't done much testing with Android at all yet, but seems to experience the same issue (when tested with the VLC app itself).
Have reproduced this bug on several iPhones and one Android phone so far.
Operating system: iOS 17.6.1 (and several more iOS versions including iOS 18 betas and iOS 17 RCs)
VLC media player version: MobileVLCKit 3.6.0 (VLC/3.0.21)
Hardware: iPhone 15 Pro Max, iPhone 15 Pro, iPhone 14 Pro Max, iPhone 13 Pro Max, iPhone XS Max, Pixel 6
Steps to reproduce:
1. Host a WiFi network with no internet access, connect your iPhone and some other device with which you can host a http stream using VLC.***
2. On that WiFi network, use a computer to host a http local network stream at an address starting with 192.168. I used an mp4 file (mp4a and H.264)
3. Open the VLC app on your iPhone and try to consume the http stream. The stream will not load. ^^^
4. Open settings on your iPhone, navigate to VLC settings and disable cellular data.
5. Return to VLC and consume your stream. It will play, beca
*** WiFi setup sounds tricky, here is what I did; I restricted my iPhone's ability to access the internet on my WiFi network through a router rule. I then hosted a http stream with an mp4 file on vlc using a MacBook Pro on the same WiFi network using this call:
vlc -vvvv ~/Desktop/CYQ_0107.MP4 --sout #'standard{access=http,mux=ts,dst=:80/CYQ_0107.MP4}'
^^^ If you use router rules to restrict network access, you may need to wait until your phone throws an error saying there is no internet access via the WiFi network, and allow cellular data use. I needed to do that, the http stream works normally until your phone realises that the WiFi network has no internet access.
Reproducibility:
On iOS 100% of streams from host on 192.168.x.x available on local network when WiFi has no internet access and device has cell data available.
On Android 100% of http streams from host on 192.168.x.x on available on local network when WiFi has no internet access and device has cell data available.
On MacOS VLC from CLI will consume the http stream correctly, even when it can access a network on ethernet with internet, and WiFi is connected to a seperate network with no internet access.
File type:
mp4, codecs MPEG4-AAC and h.264. No subs
Issue is not file specific, is related to stream setup, but happy to provide files.
Have attached verbose logging from VLC in the cases where the stream fails due to cell data being available, and the case where cell data is not available and it works. I also have a screen recording if you'd rather watch that to understand.
cell data permission allowed: https://pastebin.com/5RDQYSBQ
cell data permission not allowed: https://pastebin.com/gzRYQApz
This problem has had me stumped for a while, until I started network logging, and then I saw what was happening pretty quickly! If anyone has ideas on how to work around this in an iOS app (and it seems like I'll need to do that in Android too) please let me know, otherwise I guess I might have to just start compiling MobileVLCKit from source and tracing the issue further up the chain to try and resolve it myself, but I'd really like to not have to do that! lol