unosquare / embedio

A tiny, cross-platform, module based web server for .NET
http://unosquare.github.io/embedio
Other
1.45k stars 175 forks source link

Web Server does not work in Xamarin.iOS (IOS-17) #586

Closed RagibNoor closed 9 months ago

RagibNoor commented 11 months ago

Describe the bug I have encountered a issue while running a web server with a static folder on an actual iOS 17 device. The server functions correctly on older iOS versions it also work fine in IOS 17 simulator

Here are more details:

On the iOS 17 simulator: I can access the web server from Safari without any issues. On the actual iOS 17 device: I cannot access the web server from Safari. no error messages are displayed while running the web server.

To Reproduce Steps to reproduce the behavior:

  1. Create a xamarin ios webview app
  2. run web server from static folder

Expected behavior webview should work on actual device.

Screenshots IN simulator image (8) in actual device 2A222617-1AAD-4E61-877D-E4D5E3BA4D02

Desktop (please complete the following information):

Smartphone (please complete the following information):

Additional context https://github.com/RagibNoor/xamarin-webview

RagibNoor commented 11 months ago

@rdeago could you please check this

rdeago commented 10 months ago

Hello @RagibNoor, thanks for using EmbedIO!

I am abysmally ignorant about everything Apple-related (and almost everything mobile-related), so please take what follows as just this old man thinking aloud.

The first thing that comes to my mind, the issue being related to static files, is that some security setting on your iPad may be preventing your server from accessing the files it has to serve. This could explain why it works on the emulator, as emulators often have more relaxed security settings compared to real devices.

The only other thing that, although perfectly normal per se, has caused weird behavior with other applications is the server URL: I'd try 127.0.0.1 instead of localhost as the server address... or even *, as in http://*:4200, that is known to have worked in Apple apps in the past (see for example #470).

If you find that access to the static folder is the problem, a possible solution is zipping the folder and embedding the zip file in the server assembly as an Embedded Resource. This was apparently pretty common among Xamarin apps using EmbedIO, as you can see in #525 and #435.

I know this isn't much help; I'm sorry, but I'm definitely out of my area of expertise here. Please leave a comment here if you solve the issue, so other developers may benefit from it in the future.

RagibNoor commented 9 months ago

Using 127.0.0.1instead of localhost resolved my issue for IOS 17