title: strange urllib2 failures on some systems
body: <p>I've got a python script that simply grabs a page with urllib2, and then proceeds to use BeautifulSoup to parse that stuff. Code is:</p>
  
  <pre><code>class Foo(Bar):
      def fetch(self):
          try:
              self.mypage = urllib2.urlopen(self.url + 'MainPage.htm', timeout=30).read()
          except urllib2.URLError:
              sys.stderr.write("Error: system at %s not responding\n" % self.url)
              sys.exit(1)
  </code></pre>
  
  <p>the system I'm trying to access is remote and behind a linux router that does port forwarding between the public static ip and the lan ip of the actual system.</p>
  
  <p>I was getting failures on some systems and at first I thought about a bug in urllib2/python, or some weird TCP stuff (the http server is actually an embedded card in some industrial system). But then I tried other systems and urllib2 works as expected, and I can also correctly access the http server using links2 or wget even on systems where urllib2 fails.</p>
  
  <ul>
  <li>Ubuntu 10.04 LTS 32bit behind Apple Airport nat on remote adsl: everythin works</li>
  <li>Mac OSX 10.6 in LAN with the server, remote behind nat, etc...: everything works</li>
  <li>Ubuntu 10.04 LTS 64bit with public ip: urllib2 times out, links and wget work</li>
  <li>Gentoo Linux with public ip: urllib2 times out, links and wget work</li>
  </ul>
  
  <p>I have verified with tcpdump on the linux router (http server end) and urllib2 always completes the tcp handshake even from the problematic systems, but then it seems to hang there. I tried toggling on/off syncookies and ECN but that didn't change anything.</p>
  
  <p>How could I debug and possibly solve this issue?</p>