iPhoneHTTPServer : no response

342 views
Skip to first unread message

beaver

unread,
Nov 21, 2011, 11:47:10 AM11/21/11
to CocoaHTTPServer
Hello,

I am a newbie in developping for iOS, so please excuse me if I make
some obvious mistakes.

I'm trying to get the iPhoneHTTPServer working on the iPhone
Simulator, but I keep getting no response.
I'm working with Mac OSX Lion, XCode 4.1.
I have opened the project in XCode. It builds without a problem, I can
run it on the iPhone simulator. The log file shows the following (I
have added a call to get the ip address):

2011-11-21 17:38:14:735 iPhoneHTTPServer[925:b303]
HTTPServer[0x4e6d150]: init
2011-11-21 17:38:24:484 iPhoneHTTPServer[925:b303]
HTTPServer[0x4e6d150]: setPort:
2011-11-21 17:38:24:484 iPhoneHTTPServer[925:b303] Setting document
root: /Users/bart/Library/Application Support/iPhone Simulator/4.3.2/
Applications/D92B2124-B7FA-4000-83B9-54ACEBE16B32/iPhoneHTTPServer.app/
Web
2011-11-21 17:38:24:484 iPhoneHTTPServer[925:b303]
HTTPServer[0x4e6d150]: setDocumentRoot:
2011-11-21 17:38:24:484 iPhoneHTTPServer[925:b303]
HTTPServer[0x4e6d150]: start:
2011-11-21 17:38:24:485 iPhoneHTTPServer[925:b303] HTTPServer: Started
HTTP server on port 12345
2011-11-21 17:38:24:485 iPhoneHTTPServer[925:b303]
HTTPServer[0x4e6d150]: publishBonjour
2011-11-21 17:38:24:485 iPhoneHTTPServer[925:b303] Current IP Address:
192.168.6.129

Now, when I enter the url http://localhost:12345 into Safari, the
request times out.
When debugging the HTTPConnection.m file, it correctly enters (and
leaves) the "initialize" method, but when loading the page in Safari,
no other method is called.
Actually, I have the impression that the request never reaches the
http server.
I have tried to enter the device's IP address explicitly :
http://192.168.6.129:12345, but no cure, still no response. Nothing is
added to the application log.

The SimpleHTTPServer sample application when run from within XCode
does work fine on the Mac itself.

Any help would be much appreciated.

Thank you,

Bart

yj

unread,
Dec 6, 2011, 9:49:39 AM12/6/11
to cocoaht...@googlegroups.com
The issue is that once you leave the App, it goes into the inactive state and the web service stops running until you reopen it.

To keep the app alive in the background you could run a task. ie. play audio

Marco Peluso wrote a class to do this: MMPDeepSleepPreventer
However, in iOS 5, it doesn't work. You will need to modify it as follows:
- Remove: [self.audioPlayer setVolume:0.0];
- Choose an audio file that plays some sound

With iOS 5.0 there are 5 task you can run in the background to keep you App alive
audio
location
voip
newsstand-content
external-accessory

Hope this helps.
-Yoo-Jin

Tim K

unread,
Dec 12, 2011, 2:28:31 PM12/12/11
to CocoaHTTPServer
> Marco Peluso wrote a class to do this: MMPDeepSleepPreventer> However, in iOS 5, it doesn't work. You will need to modify it as follows:> - Remove: [self.audioPlayer setVolume:0.0];> - Choose an audio file that plays some sound

Unfortunately that does not work. Do you have a complete code example
running under ios5?
thanks for your help so far.
tim

Yoo-Jin

unread,
Dec 14, 2011, 7:00:00 AM12/14/11
to cocoaht...@googlegroups.com
Sample Code: http://code.google.com/r/yoojin-cocoahttpserver-iphone/

Run: /Samples/iPhoneHTTPServer

Also you need to test on a device if your iOS Simulator is 5.0

Blog: http://www.mokten.com/2011/12/run-a-web-server-from-an-iphone-app/

Let me know how it goes.

- Yoo-Jin
Reply all
Reply to author
Forward
0 new messages