Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MS Windows Server 2012: IOError: [Errno socket error] [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590) #15

Closed
miroi opened this issue Jun 23, 2015 · 22 comments

Comments

@miroi
Copy link
Contributor

miroi commented Jun 23, 2015

Hi,

I am opening separate issue for this task of adapting the core python script - update.py - for the MS Windows platform.

Currently it is throwing this error below. Any help is appreciated.

C:\Users\milias\Documents\work\software\autocmake\autocmake\test\fc\cmake>python update.py  --self
- fetching lib/config.py
Traceback (most recent call last):
  File "update.py", line 308, in <module>
    main(sys.argv)
  File "update.py", line 264, in main
    dst='lib/config.py'
  File "update.py", line 42, in fetch_url
    opener.retrieve(src, dst)
  File "C:\Python27\lib\urllib.py", line 245, in retrieve
    fp = self.open(url, data)
  File "C:\Python27\lib\urllib.py", line 213, in open
    return getattr(self, name)(url)
  File "C:\Python27\lib\urllib.py", line 443, in open_https
    h.endheaders(data)
  File "C:\Python27\lib\httplib.py", line 997, in endheaders
    self._send_output(message_body)
  File "C:\Python27\lib\httplib.py", line 850, in _send_output
    self.send(msg)
  File "C:\Python27\lib\httplib.py", line 812, in send
    self.connect()
  File "C:\Python27\lib\httplib.py", line 1216, in connect
    server_hostname=server_hostname)
  File "C:\Python27\lib\ssl.py", line 350, in wrap_socket
    _context=self)
  File "C:\Python27\lib\ssl.py", line 566, in __init__
    self.do_handshake()
  File "C:\Python27\lib\ssl.py", line 788, in do_handshake
    self._sslobj.do_handshake()
IOError: [Errno socket error] [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:581)

C:\Users\milias\Documents\work\software\autocmake\autocmake\test\fc\cmake>
@bast
Copy link
Member

bast commented Jun 24, 2015

The error comes from URLopener. I would recommend to debug this in an interactive session
where you look at the isolated URLopener on that machine.
What it tries and fails to do is to fetch the sources specified in autocmake.cfg. You could
try to fetch them in an interactive Python session manually to corner the problem.

@miroi
Copy link
Contributor Author

miroi commented Jun 26, 2015

Closing as this bug is irrelevant. In between I got green light for Windows tests !

@miroi miroi closed this as completed Jun 26, 2015
@miroi
Copy link
Contributor Author

miroi commented Jun 26, 2015

Well, reopening this issue - on the virtual Windows Server there is still some issue with Python !
Strange that appveyor is giving green light.

@miroi miroi reopened this Jun 26, 2015
@miroi miroi changed the title adapt update.py for MS Windows MS Windows: SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:581) Jun 26, 2015
@miroi
Copy link
Contributor Author

miroi commented Jun 26, 2015

Fresh Python 2.7.10, Windows Server 2012 (x86_64):

C:\Users\milias\Documents\work\software\autocmake-devel\autocmake>py.test -v test\test.py
============================= test session starts =============================
platform win32 -- Python 2.7.10 -- py-1.4.30 -- pytest-2.7.2 -- C:\Python27\python.exe
rootdir: C:\Users\milias\Documents\work\software\autocmake-devel\autocmake\test, inifile:
collected 2 items

test\test.py::test_cxx FAILED
test\test.py::test_fc FAILED

================================== FAILURES ===================================
__________________________________ test_cxx ___________________________________

    def test_cxx():
        os.chdir(os.path.join(HERE, 'cxx', 'cmake'))
>       update.fetch_url('https://github.com/miroi/autocmake/raw/master/update.py', 'update.py')

..\..\test.py:19:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\..\update.py:41: in fetch_url
    opener.retrieve(src, dst)
C:\Python27\lib\urllib.py:245: in retrieve
    fp = self.open(url, data)
C:\Python27\lib\urllib.py:213: in open
    return getattr(self, name)(url)
C:\Python27\lib\urllib.py:443: in open_https
    h.endheaders(data)
C:\Python27\lib\httplib.py:1049: in endheaders
    self._send_output(message_body)
C:\Python27\lib\httplib.py:893: in _send_output
    self.send(msg)
C:\Python27\lib\httplib.py:855: in send
    self.connect()
C:\Python27\lib\httplib.py:1274: in connect
    server_hostname=server_hostname)
C:\Python27\lib\ssl.py:352: in wrap_socket
    _context=self)
C:\Python27\lib\ssl.py:579: in __init__
    self.do_handshake()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <ssl.SSLSocket object at 0x0000000002BCEDD8>, block = False

    def do_handshake(self, block=False):
        """Perform a TLS/SSL handshake."""
        self._check_connected()
        timeout = self.gettimeout()
        try:
            if timeout == 0.0 and block:
                self.settimeout(None)
>           self._sslobj.do_handshake()
E           IOError: [Errno socket error] [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)

C:\Python27\lib\ssl.py:808: IOError
___________________________________ test_fc ___________________________________

    def test_fc():
        os.chdir(os.path.join(HERE, 'fc', 'cmake'))
>       update.fetch_url('https://github.com/miroi/autocmake/raw/master/update.py', 'update.py')

..\..\test.py:39:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\..\update.py:41: in fetch_url
    opener.retrieve(src, dst)
C:\Python27\lib\urllib.py:245: in retrieve
    fp = self.open(url, data)
C:\Python27\lib\urllib.py:213: in open
    return getattr(self, name)(url)
C:\Python27\lib\urllib.py:443: in open_https
    h.endheaders(data)
C:\Python27\lib\httplib.py:1049: in endheaders
    self._send_output(message_body)
C:\Python27\lib\httplib.py:893: in _send_output
    self.send(msg)
C:\Python27\lib\httplib.py:855: in send
    self.connect()
C:\Python27\lib\httplib.py:1274: in connect
    server_hostname=server_hostname)
C:\Python27\lib\ssl.py:352: in wrap_socket
    _context=self)
C:\Python27\lib\ssl.py:579: in __init__
    self.do_handshake()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <ssl.SSLSocket object at 0x0000000002C6B748>, block = False

    def do_handshake(self, block=False):
        """Perform a TLS/SSL handshake."""
        self._check_connected()
        timeout = self.gettimeout()
        try:
            if timeout == 0.0 and block:
                self.settimeout(None)
>           self._sslobj.do_handshake()
E           IOError: [Errno socket error] [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)

C:\Python27\lib\ssl.py:808: IOError
========================= 2 failed in 601.53 seconds ==========================

C:\Users\milias\Documents\work\software\autocmake-devel\autocmake>

@ghost
Copy link

ghost commented Jun 30, 2015

Try to reinstall. See email in your inbox.

@bast
Copy link
Member

bast commented Jul 1, 2015

If there is more to it than just reinstall please post the solution here so that
others who hit a similar problem can follow it. Thanks!

@miroi
Copy link
Contributor Author

miroi commented Jul 1, 2015

So far, reinstallation did not help. Something seems be wrong with ssh-connection outside.

@ghost
Copy link

ghost commented Jul 1, 2015

I am unable to reproduce your error, run in your python these commands:

import ssl
ssl.OPENSSL_VERSION
and tell me your version. Mine just works.

see picture
ssl

@miroi
Copy link
Contributor Author

miroi commented Jul 1, 2015

C:\Users\milias\Documents\work\software\autocmake-devel\autocmake_miroi_win\test>python
Python 2.7.10 (default, May 23 2015, 09:40:32) [MSC v.1500 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 1.0.2a 19 Mar 2015'
>>>

@miroi
Copy link
Contributor Author

miroi commented Jul 10, 2015

Well, after playing with virtual Windows server 2012 setting I got this type of error:

C:\Users\milias\Desktop\autocmake>c:\Python27\Scripts\py.test.exe -vv test\test.py
============================= test session starts =============================
platform win32 -- Python 2.7.10 -- py-1.4.30 -- pytest-2.7.2 -- C:\Python27\python.exe
rootdir: C:\Users\milias\Desktop\autocmake\test, inifile:
collected 2 items

test\test.py::test_cxx PASSED
test\test.py::test_fc FAILED

================================== FAILURES ===================================
___________________________________ test_fc ___________________________________

    def test_fc():
>       stdout, stderr = boilerplate('fc', 'python setup.py --fc=gfortran')

..\..\test.py:107:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\test.py:77: in boilerplate
    dst='lib/docopt.py')
..\..\test.py:43: in fetch_url
    opener.retrieve(src, dst)
C:\Python27\lib\urllib.py:245: in retrieve
    fp = self.open(url, data)
C:\Python27\lib\urllib.py:213: in open
    return getattr(self, name)(url)
C:\Python27\lib\urllib.py:457: in open_https
    return self.http_error(url, fp, errcode, errmsg, headers)
C:\Python27\lib\urllib.py:377: in http_error
    result = method(url, fp, errcode, errmsg, headers)
C:\Python27\lib\urllib.py:641: in http_error_302
    data)
C:\Python27\lib\urllib.py:667: in redirect_internal
    return self.open(newurl)
C:\Python27\lib\urllib.py:213: in open
    return getattr(self, name)(url)
C:\Python27\lib\urllib.py:443: in open_https
    h.endheaders(data)
C:\Python27\lib\httplib.py:1049: in endheaders
    self._send_output(message_body)
C:\Python27\lib\httplib.py:893: in _send_output
    self.send(msg)
C:\Python27\lib\httplib.py:855: in send
    self.connect()
C:\Python27\lib\httplib.py:1274: in connect
    server_hostname=server_hostname)
C:\Python27\lib\ssl.py:352: in wrap_socket
    _context=self)
C:\Python27\lib\ssl.py:579: in __init__
    self.do_handshake()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <ssl.SSLSocket object at 0x0000000002D60128>, block = False

    def do_handshake(self, block=False):
        """Perform a TLS/SSL handshake."""
        self._check_connected()
        timeout = self.gettimeout()
        try:
            if timeout == 0.0 and block:
                self.settimeout(None)
>           self._sslobj.do_handshake()
E           IOError: [Errno socket error] [Errno 10054] An existing connection was forcibly closed by the remote host

C:\Python27\lib\ssl.py:808: IOError
===================== 1 failed, 1 passed in 4.99 seconds ======================

C:\Users\milias\Desktop\autocmake>

@miroi miroi changed the title MS Windows: SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:581) MS Windows Server 2012: [Errno 10054] An existing connection was forcibly closed by the remote host Jul 11, 2015
@miroi
Copy link
Contributor Author

miroi commented Jul 11, 2015

Fixed according to the http://sickbeard.com/forums/viewtopic.php?f=4&t=9833

As admin on MS Windows 2012 I run this (dos) command:

netsh int tcp set global ecncapability=disabled

and both tests are fine !

C:\Users\milias\Documents\work\autocmake-devel\autocmake>py.test -vv test\test.py
============================= test session starts =============================
platform win32 -- Python 2.7.10 -- py-1.4.30 -- pytest-2.7.2 -- C:\Python27\python.exe
rootdir: C:\Users\milias\Documents\work\autocmake-devel\autocmake\test, inifile:
collected 2 items

test\test.py::test_cxx PASSED
test\test.py::test_fc PASSED

========================== 2 passed in 3.48 seconds ===========================

C:\Users\milias\Documents\work\autocmake-devel\autocmake>

@miroi miroi closed this as completed Jul 11, 2015
@miroi
Copy link
Contributor Author

miroi commented Sep 4, 2015

Reopening this issue.

Again, my virtual MS Windows Server 2012 got the samer error, though the command that worked perviously, is not working:

Microsoft Windows [Version 6.2.9200]
(c) 2012 Microsoft Corporation. All rights reserved.

C:\Windows\system32>netsh int tcp set global ecncapability=disabled
Ok.

The error message is

___________________________ test_cc_clapack_static ____________________________

    def test_cc_clapack_static():
>       configure_build_and_exe('cc_clapack', 'python setup.py --cc=gcc --static --cmake-options="-DMATH_LIB_SEARCH_ORDER=\'O
PENBLAS;ATLAS;MKL;SYSTEM_NATIVE\'"')

..\..\test.py:214:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\test.py:89: in configure_build_and_exe
    dst='lib/docopt.py')
..\..\test.py:49: in fetch_url
    opener.retrieve(src, dst)
C:\Python27\lib\urllib.py:245: in retrieve
    fp = self.open(url, data)
C:\Python27\lib\urllib.py:213: in open
    return getattr(self, name)(url)
C:\Python27\lib\urllib.py:443: in open_https
    h.endheaders(data)
C:\Python27\lib\httplib.py:1049: in endheaders
    self._send_output(message_body)
C:\Python27\lib\httplib.py:893: in _send_output
    self.send(msg)
C:\Python27\lib\httplib.py:855: in send
    self.connect()
C:\Python27\lib\httplib.py:1274: in connect
    server_hostname=server_hostname)
C:\Python27\lib\ssl.py:352: in wrap_socket
    _context=self)
C:\Python27\lib\ssl.py:579: in __init__
    self.do_handshake()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <ssl.SSLSocket object at 0x00000000038E2EB8>, block = False

    def do_handshake(self, block=False):
        """Perform a TLS/SSL handshake."""
        self._check_connected()
        timeout = self.gettimeout()
        try:
            if timeout == 0.0 and block:
                self.settimeout(None)
>           self._sslobj.do_handshake()
E           IOError: [Errno socket error] [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)

C:\Python27\lib\ssl.py:808: IOError

@miroi miroi reopened this Sep 4, 2015
@miroi miroi changed the title MS Windows Server 2012: [Errno 10054] An existing connection was forcibly closed by the remote host MS Windows Server 2012: IOError: [Errno socket error] [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590) Sep 4, 2015
@miroi
Copy link
Contributor Author

miroi commented Sep 4, 2015

Again, connectivity issue on MS Windows Server 2012...

Rado (@bast), please don't you know some trick to check it ?

C:\Users\milias\Documents\work\autocmake-devel\autocmake\test\fc\cmake>python update.py --self
- creating .gitignore
- fetching lib/config.py
Traceback (most recent call last):
  File "update.py", line 483, in <module>
    main(sys.argv)
  File "update.py", line 334, in main
    dst='lib/config.py'
  File "update.py", line 44, in fetch_url
    opener.retrieve(src, dst)
  File "C:\Python27\lib\urllib.py", line 245, in retrieve
    fp = self.open(url, data)
  File "C:\Python27\lib\urllib.py", line 213, in open
    return getattr(self, name)(url)
  File "C:\Python27\lib\urllib.py", line 443, in open_https
    h.endheaders(data)
  File "C:\Python27\lib\httplib.py", line 1049, in endheaders
    self._send_output(message_body)
  File "C:\Python27\lib\httplib.py", line 893, in _send_output
    self.send(msg)
  File "C:\Python27\lib\httplib.py", line 855, in send
    self.connect()
  File "C:\Python27\lib\httplib.py", line 1274, in connect
    server_hostname=server_hostname)
  File "C:\Python27\lib\ssl.py", line 352, in wrap_socket
    _context=self)
  File "C:\Python27\lib\ssl.py", line 579, in __init__
    self.do_handshake()
  File "C:\Python27\lib\ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
IOError: [Errno socket error] [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)

C:\Users\milias\Documents\work\autocmake-devel\autocmake\test\fc\cmake>

@bast
Copy link
Member

bast commented Sep 4, 2015

The only advice I can give is to not debug this using the update.py script but directly in the Python shell:
https://github.com/scisoft/autocmake/blob/master/update.py#L43-L44

@miroi
Copy link
Contributor Author

miroi commented Sep 4, 2015

Rado ( @bast),

would you please agree with error catching ?

An example here

    opener = URLopener()
    try:
        opener.retrieve(src, dst)
    except:
        print "src=",src
        print "dst=",dst
        print "opener.retrieve(src, dst) gave error:", sys.exc_info()[0]
        sys.exit("error in opener.retrieve(src, dst)!")

giving output of

C:\Users\milias\Documents\work\autocmake-devel\autocmake\test\fc\cmake>python update.py  --self
- fetching lib/config.py
src= https://github.com/scisoft/autocmake/raw/master/lib/config.py
dst= lib/config.py
Unexpected error: <type 'exceptions.IOError'>
error in opener.retrieve(src, dst)!

@bast
Copy link
Member

bast commented Sep 4, 2015

If you need this for debugging, just introduce it on your fork until you debug the problem. I don't think we need the debugging code in the central repo, right?

@miroi
Copy link
Contributor Author

miroi commented Sep 4, 2015

OK, debugging in not necessary for now; firt, first I have to find the reason for the connectivity failure on MS Windows Server 2012....

>>> import urllib
>>> urllib.urlretrieve(url="https://github.com/scisoft/autocmake/raw/master/lib/config.py")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python27\lib\urllib.py", line 98, in urlretrieve
    return opener.retrieve(url, filename, reporthook, data)
  File "C:\Python27\lib\urllib.py", line 245, in retrieve
    fp = self.open(url, data)
  File "C:\Python27\lib\urllib.py", line 213, in open
    return getattr(self, name)(url)
  File "C:\Python27\lib\urllib.py", line 443, in open_https
    h.endheaders(data)
  File "C:\Python27\lib\httplib.py", line 1049, in endheaders
    self._send_output(message_body)
  File "C:\Python27\lib\httplib.py", line 893, in _send_output
    self.send(msg)
  File "C:\Python27\lib\httplib.py", line 855, in send
    self.connect()
  File "C:\Python27\lib\httplib.py", line 1274, in connect
    server_hostname=server_hostname)
  File "C:\Python27\lib\ssl.py", line 352, in wrap_socket
    _context=self)
  File "C:\Python27\lib\ssl.py", line 579, in __init__
    self.do_handshake()
  File "C:\Python27\lib\ssl.py", line 808, in do_handshake
    self._sslobj.do_handshake()
IOError: [Errno socket error] [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:590)

@bast
Copy link
Member

bast commented Sep 8, 2015

Duplicate of #117. Closing.

@bast bast closed this as completed Sep 8, 2015
@miroi
Copy link
Contributor Author

miroi commented Sep 9, 2015

Excellent, Rado !

Connectivity on my MS Windows Server 2012 is renewed !

C:\Users\milias\Documents\work\autocmake-devel\autocmake>py.test -vv test\test.py
============================= test session starts =============================
platform win32 -- Python 2.7.10 -- py-1.4.30 -- pytest-2.7.2 -- C:\Python27\python.exe
rootdir: C:\Users\milias\Documents\work\autocmake-devel\autocmake\test, inifile:
collected 27 items

test\test.py::test_cxx_custom PASSED
test\test.py::test_extra_cmake_options PASSED
test\test.py::test_cxx PASSED
test\test.py::test_cxx_static PASSED
test\test.py::test_fc PASSED�
.
.
.

@bast
Copy link
Member

bast commented Sep 9, 2015

To be precise, connectivity is not renewed - it is still broken on that server - but now we completely avoid connectivity during tests.

@freenaut
Copy link

@miroi i got same err , how to fixed it?

@bast
Copy link
Member

bast commented Mar 18, 2016

@freenaut is the problem still there?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants