5

I'm using NSURLConnection to access a web service (on a .local host). When I access the host by hostname, I'm seeing a delay of 5+ seconds, but when I access it by IP, the connection completes almost instantly. Running the app on an actual iPhone, instead of the simulator, does not show any delays at all (testing was done on the same network connection). So this seems to be a problem specific to the iOS Simulator or OS X.

I'm able to simulate the problem using the following terminal commands:

nslookup webservice.myhost.local (which is fast)

dscacheutil -q host -a name webservice.myhost.local (shows the delay)

When analyzing the network traffic using Wireshark of the dscacheutil command, I'm seeing several Standard query AAAA requests which are marked red and get an empty response. Once these are done, I see a Standard query A request which has a response containing the correct IP address. The AAAA requests take up about 5 seconds, which would explain the delay.

René
  • 2,912
  • 1
  • 28
  • 46
  • You could make screenshots of such packets and put it somwhere on the web (imageshack.us e.g. or your own site). – ott-- Nov 11 '11 at 19:13

3 Answers3

4

Does the web service perhaps have IPv6 enabled and you can't use that from the simulator?

I see this on OSX for example when running a local IPv4 only DNS service - if I run dig @localhost is hangs for some seconds until the initial IPv6 connection times out, and then it tries IPv4.

Alnitak
  • 334,560
  • 70
  • 407
  • 495
  • I think the problem is indeed IPv6 related. Could this perhaps be the problem? https://en.wikipedia.org/wiki/IPv6_brokenness Even though I'm on a local network? – René Nov 14 '11 at 17:22
  • It won't be DNS whitelisting - that's a technique used by content providers to ensure that only known "working" IPv6 capable ISPs try to send their users over IPv6. – Alnitak Nov 15 '11 at 08:28
  • Okay. Well, I'll award the points to you, because it's definitely IPv6 related. Hopefully my IT dept. will be able to find out what's causing it. I'll update the post if they do. – René Nov 15 '11 at 09:41
  • Did you ever find a solution? I'm currently developing an iPad web app and this bug is really annoying and costs a lot of time. – Jonathan Apr 23 '12 at 22:44
2

This answer solved the problem for me. (Create an IPv6 ::1 loopback entry to go along with each 127.0.0.1.)

Community
  • 1
  • 1
slowernet
  • 43
  • 1
  • 1
  • 7
1

For anyone else who stumbles across this issue... I myself had to disable IPv6 on my machine to avoid the hang in the simulator while IPv6 fails. I did so following these instructions: https://discussions.apple.com/message/18097613#18097613

Which were to:

"To disable IPv6 in OS X Lion, you will need to use the Terminal.

Applications > Utilities > Terminal

To determine what are all of your Mac's network interfaces are, issue the following command: networksetup -listallnetworkservices

To disable IPv6 for wireless, issue the following command: networksetup -setv6off Wi-Fi;

To disable IPv6 for Ethernet, issue the following command: networksetup -setv6off Ethernet

To re-enable IPv6, use -setv6automatic instead"

Kurzee
  • 36
  • 2