I am coping with two internal web servers, one running Apache2 on Ubuntu Server 10.04, and also the other IIS on Home windows Server 2008. After I hit either from the root Web addresses from the internet browser having a removed cache, calling the server by Ip, both appear without any delay. I additionally see no delays browsing sites on either server. However, after i call exactly the same addresses using urllib2 in Python, each request towards the Apache2 server is postponed by 4.5 to five seconds. The IIS server responds in under .02.

This is a script I went to ensure the issue. I set the consumer-Agent just in case it is important, however it does not seem to:

import urllib2
from time import time

apache_server = 'http://192.168.1.101/'
iis_server = 'http://192.168.1.102/'

headers = {'User-Agent' : "Mozilla/5.0 (X11; U; Linux i586; de; rv:5.0) Gecko/20100101 Firefox/5.0",}

print('Contacting Apache2 server...')
request = urllib2.Request(url=apache_server, headers=headers)
start = time()
response = urllib2.urlopen(request).read()
elapsed = time() - start
print('Elapsed time: {0}'.format(elapsed))

print('Contacting IIS server...')
request = urllib2.Request(url=iis_server, headers=headers)
start = time()
response = urllib2.urlopen(request).read()
elapsed = time() - start
print('Elapsed time: {0}'.format(elapsed))

Results:

>python urltest.py
Contacting Apache2 server...
Elapsed time: 4.55500006676

Contacting IIS server...
Elapsed time: 0.0159997940063

What difference can there be from a browser request and my urllib2 request that will explain this delay?

I have seen similar issues with SSH triggered by reverse DNS research, however i have HostnameLookups Off during my Apache2 config. I'm not sure contrary else might be triggering a research.


Update: I adopted the exchange with Wireshark, and located three unsuccessful NBNS queries going from my machine towards the Apache2 server before they finally start speaking. This paid for for that lost time. I attempted adding an entry in hosts for that web server, which removed the delay.

I am not adding this being an answer because I still have no idea why the research attempt is going on, or why I do not begin to see the same behavior in the internet browser. I simply possess a workaround for whatever mistake I am making.

The research is going on because that is what Home windows does. It certainly is likely to check NetBIOS before other things.

Further reading through: