Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

_ssl.c errors #333

Open
KOLANICH opened this issue Jul 4, 2017 · 11 comments
Open

_ssl.c errors #333

KOLANICH opened this issue Jul 4, 2017 · 11 comments

Comments

@KOLANICH
Copy link
Contributor

KOLANICH commented Jul 4, 2017

en.wikipedia.org -> _ssl.c:733: The handshake operation timed out
github.com, google.com, yandex.ru -> SSLError: [SSL: UNKNOWN_PROTOCOL] unknown protocol (_ssl.c:749)
twitter.com -> SSLEOFError: EOF occured in violation of protocol (_ssl.c:749)

@Lukasa
Copy link
Member

Lukasa commented Jul 4, 2017

In all of these cases it's very hard to know without additional details what's going on. What version of Python and OpenSSL are you using?

@KOLANICH
Copy link
Contributor Author

KOLANICH commented Jul 4, 2017

Anaconda custom-py36_0 based on 4.4.0-np112py36_1 x86 (32 bit) (just fully updated that version)
python 3.6.1.final.0

@Lukasa
Copy link
Member

Lukasa commented Jul 4, 2017

What about OpenSSL?

@KOLANICH
Copy link
Contributor Author

KOLANICH commented Jul 4, 2017

openssl 1.0.2l (as reported by conda list openssl)

@Lukasa
Copy link
Member

Lukasa commented Jul 4, 2017

Hrm. Can you show me some sample code that reproduces the issue?

@KOLANICH
Copy link
Contributor Author

KOLANICH commented Jul 4, 2017

@Lukasa
Copy link
Member

Lukasa commented Jul 4, 2017

Hrm, this is not obviously problematic. Are you familiar with Wireshark? If you are, it'd be helpful to see the pcap for one of these failing transactions.

@KostyaEsmukov
Copy link
Contributor

You need to specify a port along with hostname.

--- t.original.py	2017-07-31 14:41:55.000000000 +0300
+++ t.fixed.py	2017-07-31 14:43:29.000000000 +0300
@@ -2,11 +2,13 @@
 from urllib.parse import urlparse
 from hyper import HTTPConnection

+default_port = dict(http=80, https=443)
+
 def makeActualReq(uri, referer=None, maxRedirects=10):
 	if maxRedirects<=0:
 		raise Exception("Redirects limit reached")
 	u=urlparse(uri)
-	with HTTPConnection(u.hostname, secure=(u.scheme=="https")) as conn:
+	with HTTPConnection(u.hostname, port=(u.port or default_port.get(u.scheme.lower())), secure=(u.scheme=="https")) as conn:
 		#print(u.path)
 		conn.request('GET', u.path)
 		resp=conn.get_response()

@KOLANICH
Copy link
Contributor Author

Thank you, it looks like HTTP11Connection should be modified.

@peterbe
Copy link

peterbe commented Apr 24, 2019

Thanks for that tip @KostyaEsmukov
It helped me here: #408 (comment)

@peterbe
Copy link

peterbe commented Apr 24, 2019

See this comment: #407 (comment)

I was running pytest with hyper in Python 3.7 and was getting that SSL warning. But as soon as I installed ndg-httpsclient that (same) SSL error disappeared.

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

No branches or pull requests

4 participants