httpswift / swifter

Tiny http server engine written in Swift programming language.
BSD 3-Clause "New" or "Revised" License
3.9k stars 537 forks source link

Swifter does not work on iOS Device in Background #42

Open flashspys opened 9 years ago

flashspys commented 9 years ago

Swifter does not start its server in a UIBackgroundTask That is the reason why the Swifter Demo App does not work on a real iOS Device but in iOS Simulator. It's very important to start the server in a Background Task. Otherwise the app wont answer for Example to the request when you access your webpage from MobileSafari!

tristaaan commented 9 years ago

hmm... I've been using Swifter in production and have had no problems running it on a device. https://github.com/Kitware/arctic-viewer-ios

flashspys commented 9 years ago

Maybe try the following: Start the Swifter Demo App on a real device. Then press home button and open Safari and try to access localhost:8080 . On my devices it wont load. Only after I switch back to Demo App and switch back again to Safari I can see the loaded content

tristaaan commented 9 years ago

For what it's worth, I'm using the last version of swifter compatible with Swift 1.2. Perhaps something small has changed that causes the reported issue?

sjbodzo commented 9 years ago

I notice the same behavior as tristaaan. The application cannot run in the background, so it must have focus on your iPhone to process your requests. Additionally, I cannot connect to the web server from other devices on the network.

tristaaan commented 9 years ago

If you'd like to try the application I mentioned App Store link, but again it's using an older version of swifter. I see the backgrounding problem now, but while the app is active I've had no problems accessing the server from other computers and devices on the same network.

flashspys commented 9 years ago

When the app is active, everything works as far as I know fine. But I think Swifter should handle the situation that the webserver is called when Swifter is in background.

kaaaaai commented 2 years ago

I have the same problem. Have anyone solved it?