<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-2">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0cm;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:"Courier New";}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@page WordSection1
{size:612.0pt 792.0pt;
margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hello all,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I am trying to find out the reason for some weird behavior on Windows.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">We have the following code:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">import urllib2<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New""><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">req = urllib2.Request("https://benotificationsmock.cloudapp.net:8443")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">resp = urllib2.urlopen(req, timeout = 5)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:10.0pt;font-family:"Courier New"">print resp.code<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">This simple script should print “200”. However, all I ever get when running this on any Windows machine (for reference, mine is Windows 7, Python 2.7.3 and OpenSSL 1.0.0c / 0.9.8x) is the following exception:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Traceback (most recent call last):<o:p></o:p></p>
<p class="MsoNormal"> File "foo.py", line 5, in <module><o:p></o:p></p>
<p class="MsoNormal"> resp = urllib2.urlopen(req, timeout = 5)<o:p></o:p></p>
<p class="MsoNormal"> File "C:\Python27\lib\urllib2.py", line 126, in urlopen<o:p></o:p></p>
<p class="MsoNormal"> return _opener.open(url, data, timeout)<o:p></o:p></p>
<p class="MsoNormal"> File "C:\Python27\lib\urllib2.py", line 400, in open<o:p></o:p></p>
<p class="MsoNormal"> response = self._open(req, data)<o:p></o:p></p>
<p class="MsoNormal"> File "C:\Python27\lib\urllib2.py", line 418, in _open<o:p></o:p></p>
<p class="MsoNormal"> '_open', req)<o:p></o:p></p>
<p class="MsoNormal"> File "C:\Python27\lib\urllib2.py", line 378, in _call_chain<o:p></o:p></p>
<p class="MsoNormal"> result = func(*args)<o:p></o:p></p>
<p class="MsoNormal"> File "C:\Python27\lib\urllib2.py", line 1215, in https_open<o:p></o:p></p>
<p class="MsoNormal"> return self.do_open(httplib.HTTPSConnection, req)<o:p></o:p></p>
<p class="MsoNormal"> File "C:\Python27\lib\urllib2.py", line 1177, in do_open<o:p></o:p></p>
<p class="MsoNormal"> raise URLError(err)<o:p></o:p></p>
<p class="MsoNormal">urllib2.URLError: <urlopen error timed out><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><span lang="RO">Firewalls are not at fault here, as netstat reports that the connection is being established. The only problem is that reading from the socket seems to fail.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="RO">The exact same code runs fine on Linux. The only way to make it work on Windows is to remove the non-standard port.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="RO"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="RO">Did anyone else encounter this weird behavior? Can anyone give any suggestions? Any feedback would be greatly appreciated.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="RO"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="RO">Best regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="RO">Claudiu<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="RO"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="RO">-- <o:p></o:p></span></p>
<p class="MsoNormal"><span lang="RO">Claudiu CURCĂ<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="RO"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="RO">Software Development Engineer in Test II / Backend Core Prague / Microsoft Skype Division<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="RO">Telephone: +40 741 289 849<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="RO">Skype: claudiu_curca<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>