Slow DNS lookup on iOS simulator

I am using NSURLConnection to access the web service (on the .local host). When I access the host by the host name, I see a delay of 5+ seconds, but when I access it by IP, the connection ends almost instantly. Running the application on a real iPhone instead of a simulator does not cause any delays (testing was carried out with the same network connection). So this seems to be a problem specific to iOS Simulator or OS X.

I can 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 network traffic using the dscacheutil command of the dscacheutil command dscacheutil I see several Standard query AAAA requests that are marked in red and receive an empty answer. Once they are completed, I see the query Standard query A , which has a response containing the correct IP address. AAAA requests take about 5 seconds, which explains the delay.

+4
source share
3 answers

Perhaps the web service has IPv6 enabled and you cannot use this from the simulator?

I see this in OSX, for example, when I start the local DNS service for IPv4 only - if I run dig @localhost , it hangs for a few seconds until the initial IPv6 connection expires, and then it tries to perform IPv4.

+3
source

This answer solved the problem for me. (Create an IPv6 :: 1 loop entry for each 127.0.0.1.)

+2
source

For anyone who stumbles on this issue ... I myself had to disable IPv6 on my machine to avoid freezing in the simulator, while IPv6 fails. I followed the following instructions: https://discussions.apple.com/message/18097613#18097613

Who needed:

"To disable IPv6 in OS X Lion, you will need to use a terminal.

Applications> Utilities> Terminal

To determine which Mac network interfaces you have, run the following command: networksetup -listallnetworkservices

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

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

To enable IPv6 again, use -setv6automatic instead.

+1
source

Source: https://habr.com/ru/post/1380266/


All Articles