Search code examples
iosgcdwebserver

iOS: GCDWebServer does not work on device


I use GCDWebServer, precisely WebUploader. When I test it on the iPhone Simulator then everything works, but on the device I cannot see web page when I enter e.g. http://192.168.2.4:8080 to the browser. I got Connection timed out from the browser.

I am connected with the WiFi to the same network, I don't see any errors in the console, so what can be wrong? I use iOS 8.


Solution

  • Are you sure you are using the correct port? When running on an iOS device, the default port is 80, not 8080.

    Check the log in Xcode when the app is running, it will tell exactly what the IP address and port for GCDWebServer.

    The fact that you are getting a time out connection however instead of a not found error could mean that something else is preventing the connection from opening. Make sure the app is the active one on your iOS device, otherwise the server might be suspended.

    Also try restarting your iOS device, there's a rare bug in iOS where a listening socket previously used by an app can remain "stuck" for a few minutes even if the app has been killed.

    If this still doesn't work, then it's more than likely a WiFi router problem where traffic is blocked between your computer and your iOS device.