Skip to content

Xojo.Net.HTTPSocket Speed on Windows

There’s been a bit of discussion about how the new Xojo.Net.HTTPSocket is slow for some users on Windows, which we’ve been trying to isolate to get fixed.

After a bit of experimentation this January we were able to isolate one huge cause of this annoying behavior. Unfortunately it has to do with a misconfigured IPv6 DNS server configuration and whether or not yours is correct may be up to your service provider.

Whose bug is this?

According to the spec, IPv6 DNS servers are supposed to return immediately if they can’t fulfill the request. Unfortunately this is almost the exact opposite of what an IPv4 DNS server does, in that it may forward your request to the next server to see if it knows where your request should go. Unfortunately we found that only about two-thirds of the ones we tested were correctly configured.

On macOS and Linux, DNS requests are sent concurrently, that is, two requests are sent at the same time, one each for IPv4 and IPv6. The one that returns first is used. On Windows, the requests are unfortunately sent sequentially, IPv6 and then IPv4. What this means is that IPv6 requests just hang there, waiting for a response that will either never come or will wait until the underlying socket reaches its timeout. When that fails, the IPv4 request is sent and fulfilled and your socket request goes through.

What To Do

Here are a few things you can do to test this theory. While you can’t really ask all of your users to do this, it will tell you if this is where the problem lies.

  1. Turn off IPv6.
    1. Click Start and then Settings.
    2. Search for Network Connections.
    3. Click View network connections.
    4. Right-click on the active connection and select Properties.
    5. On the Networking tab, clear the Internet Protocol Version 6 (TCP/IPv6) check box, and then click OK.
  2. Change the DNS entries for IPv6 from the defaults to point to Google Public DNS or OpenDNS.
  3. Make a Hosts file entry. If your installer runs as an administrator, you can make an entry in the hosts file to force the computer to use IPv4. This is not a long term solution as the world moves to IPv6.The hosts file on Windows 7/8/10 is located at:
    C:\Windows\System32\drivers\etc

    and you should add an entry which looks like this:

    Server IP Address<TAB>domain name
  4. If it’s a domain that you control, make sure you only use IPv4 DNS entries and that your server is only listening on the IPv4 interface.

All in all, it’s a frustrating problem. While there’s no easy solution, the good news is that because there are no IPv4 addresses left to be distributed, the world is moving to IPv6. The more demand there is, the more likely that the incorrect DNS servers will get fixed because they’ll cause problems for other sites as well.