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

URLError: <urlopen error [Errno 8] _ssl.c:510: EOF occurred in violation of protocol> #4578

Closed
robbiewu008 opened this issue Dec 27, 2014 · 20 comments

Comments

@robbiewu008
Copy link

@robbiewu008 robbiewu008 commented Dec 27, 2014

D:\50_Vendors\01_Google\01_Google_IO\2014\Talk Videos>youtube-dl.exe -c -f 22 --no-check-certificate
https://www.youtube.com/watch?v=wtLJPvx7-ys -v
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['-c', '-f', '22', '--no-check-certificate', 'https://www.youtube.com/wat
ch?v=wtLJPvx7-ys', '-v']
[debug] Encodings: locale cp936, fs mbcs, out cp936, pref cp936
[debug] youtube-dl version 2014.12.17.2
[debug] Python version 2.7.8 - Windows-7-6.1.7601-SP1
[debug] exe versions: none
[debug] Proxy map: {'ftp': 'ftp://10.0.0.13:2516', 'http': 'http://10.0.0.13:2516', 'https': 'https:
//10.0.0.13:2516'}
[youtube] wtLJPvx7-ys: Downloading webpage
[youtube] wtLJPvx7-ys: Extracting video information
[youtube] wtLJPvx7-ys: Downloading DASH manifest
[debug] Invoking downloader on u'https://r5---sn-a5m7lne7.googlevideo.com/videoplayback?ratebypass=y
es&expire=1419681181&ipbits=0&mm=31&ms=au&mt=1419659558&upn=mFj-kFhUQqk&mv=m&signature=0C2E1442517D1
569BBAD039DDCEF1B7CBD2DA0E5.B28D5A2A466FB860191C1266FE6E99AB9FFA6364&requiressl=yes&mime=video%2Fmp4
&gcr=us&sver=3&dur=8889.341&itag=22&key=yt5&ip=198.71.90.52&source=youtube&initcwndbps=12513750&id=o
-AMC76ebqZMqwXocs4GY_HCKcwWnwnvGLsbH8GLkdV463&fexp=900718%2C927622%2C932404%2C939981%2C941004%2C9439
17%2C945067%2C945323%2C947209%2C947218%2C948124%2C952302%2C952605%2C952901%2C955301%2C957103%2C95710
5%2C957201&sparams=dur%2Cgcr%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Cmime%2Cmm%2Cms%2Cmv%2Cratebyp
ass%2Crequiressl%2Csource%2Cupn%2Cexpire'
ERROR: unable to download video data: <urlopen error [Errno 8] _ssl.c:510: EOF occurred in violation
of protocol>
Traceback (most recent call last):
File "youtube_dl\YoutubeDL.pyo", line 1136, in process_info
File "youtube_dl\YoutubeDL.pyo", line 1112, in dl
File "youtube_dl\downloader\common.pyo", line 297, in download
File "youtube_dl\downloader\http.pyo", line 67, in real_download
File "youtube_dl\YoutubeDL.pyo", line 1370, in urlopen
File "urllib2.pyo", line 404, in open
File "urllib2.pyo", line 422, in _open
File "urllib2.pyo", line 382, in _call_chain
File "youtube_dl\utils.pyo", line 421, in https_open
File "urllib2.pyo", line 1184, in do_open
URLError: <urlopen error [Errno 8] _ssl.c:510: EOF occurred in violation of protocol>

@robbiewu008
Copy link
Author

@robbiewu008 robbiewu008 commented Dec 27, 2014

Windows 7 64 bit, set global IE proxy with "10.0.0.13:2516", the proxy server is an Android Phone running fqrouter 2.12.2, shared its VPN connect for others with HTTP Proxy.

@robbiewu008
Copy link
Author

@robbiewu008 robbiewu008 commented Dec 27, 2014

D:\BUILD\youtube-dl-2014.12.17.2>python -m youtube_dl -v -c -f 22 --no-check-certificate https://ww
w.youtube.com/watch?v=wtLJPvx7-ys
[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['-v', '-c', '-f', '22', '--no-check-certificate', 'https://www.youtube.c
om/watch?v=wtLJPvx7-ys']
[debug] Encodings: locale cp936, fs mbcs, out cp936, pref cp936
[debug] youtube-dl version 2014.12.17.2
[debug] Python version 3.4.2 - Windows-7-6.1.7601-SP1
[debug] exe versions: none
[debug] Proxy map: {'http': 'http://10.0.0.13:2516', 'https': 'https://10.0.0.13:2516', 'ftp': 'ftp:
//10.0.0.13:2516'}
[youtube] wtLJPvx7-ys: Downloading webpage
[youtube] wtLJPvx7-ys: Extracting video information
[youtube] wtLJPvx7-ys: Downloading DASH manifest
[debug] Invoking downloader on 'https://r5---sn-nx57yne7.googlevideo.com/videoplayback?dur=8889.341&
mime=video%2Fmp4&gcr=cn&initcwndbps=4331250&expire=1419682487&itag=22&requiressl=yes&sparams=dur%2Cg
cr%2Cid%2Cinitcwndbps%2Cip%2Cipbits%2Citag%2Cmime%2Cmm%2Cms%2Cmv%2Cratebypass%2Crequiressl%2Csource%
2Cupn%2Cexpire&upn=VNrTlvThu5Q&mm=31&source=youtube&fexp=900718%2C916608%2C922244%2C923345%2C927622%
2C929305%2C932404%2C937227%2C937420%2C9405738%2C941004%2C942629%2C943917%2C947209%2C947218%2C948124%
2C948703%2C952302%2C952605%2C952901%2C955301%2C957103%2C957105%2C957201&signature=F7C19CB617DC0510DB
1E8BC77CA5410EEDE7C5F8.BDAA5879C8F990DB0838A7828D2C415852E91A50&ip=162.250.235.106&ratebypass=yes&ip
bits=0&key=yt5&sver=3&mt=1419660825&mv=m&id=o-ADi5VzxxYVLuJnLxna9nj7E5GmQHOmSaJ60VBm_DFFwO&ms=au'
ERROR: unable to download video data: <urlopen error EOF occurred in violation of protocol (_ssl.c:6
00)>
Traceback (most recent call last):
File "C:\Python34\lib\urllib\request.py", line 1174, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "C:\Python34\lib\http\client.py", line 1090, in request
self._send_request(method, url, body, headers)
File "C:\Python34\lib\http\client.py", line 1128, in _send_request
self.endheaders(body)
File "C:\Python34\lib\http\client.py", line 1086, in endheaders
self._send_output(message_body)
File "C:\Python34\lib\http\client.py", line 924, in _send_output
self.send(msg)
File "C:\Python34\lib\http\client.py", line 859, in send
self.connect()
File "C:\Python34\lib\http\client.py", line 1230, in connect
server_hostname=sni_hostname)
File "C:\Python34\lib\ssl.py", line 364, in wrap_socket
_context=self)
File "C:\Python34\lib\ssl.py", line 578, in init
self.do_handshake()
File "C:\Python34\lib\ssl.py", line 805, in do_handshake
self._sslobj.do_handshake()
ssl.SSLEOFError: EOF occurred in violation of protocol (_ssl.c:600)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\BUILD\youtube-dl-2014.12.17.2\youtube_dl\YoutubeDL.py", line 1136, in process_info
success = dl(filename, info_dict)
File "D:\BUILD\youtube-dl-2014.12.17.2\youtube_dl\YoutubeDL.py", line 1112, in dl
return fd.download(name, info)
File "D:\BUILD\youtube-dl-2014.12.17.2\youtube_dl\downloader\common.py", line 297, in download
return self.real_download(filename, info_dict)
File "D:\BUILD\youtube-dl-2014.12.17.2\youtube_dl\downloader\http.py", line 67, in real_download
data = self.ydl.urlopen(request)
File "D:\BUILD\youtube-dl-2014.12.17.2\youtube_dl\YoutubeDL.py", line 1370, in urlopen
return self._opener.open(req, timeout=self._socket_timeout)
File "C:\Python34\lib\urllib\request.py", line 455, in open
response = self._open(req, data)
File "C:\Python34\lib\urllib\request.py", line 473, in _open
'_open', req)
File "C:\Python34\lib\urllib\request.py", line 433, in _call_chain
result = func(*args)
File "C:\Python34\lib\urllib\request.py", line 1217, in https_open
context=self._context, check_hostname=self._check_hostname)
File "C:\Python34\lib\urllib\request.py", line 1176, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error EOF occurred in violation of protocol (_ssl.c:600)>

D:\BUILD\youtube-dl-2014.12.17.2>

@robbiewu008
Copy link
Author

@robbiewu008 robbiewu008 commented Dec 27, 2014

I can watch the Youtube videos online with the Global IE proxy (10.0.0.13:2516). I can download the videos with Chrome Browser (visiting en.savefrom.net). Now failure with Youtube-DL.

@phihag
Copy link
Contributor

@phihag phihag commented Dec 27, 2014

Reopening; we should ensure that youtube-dl works with broken SSL implemenations like Global IE proxy as well, by default.

@phihag phihag reopened this Dec 27, 2014
@roosemberth
Copy link

@roosemberth roosemberth commented Apr 21, 2016

having the same issue with tsocks + youtube-dl 2016.03.26

Update: I solved this issue by using proxychains, now it works without any problem

@anirudh-ramesh
Copy link

@anirudh-ramesh anirudh-ramesh commented May 7, 2016

Encountered isolated incident throwing <urlopen error EOF occurred in violation of protocol (_ssl.c:590)> with v2016.04.01. Triggering an automatic retry could be helpful, perhaps.

@terefang
Copy link

@terefang terefang commented Jul 18, 2016

i edited "youtube_dl/utils.py":

def make_HTTPS_handler(opts_no_check_certificate, **kwargs):
if sys.version_info < (3, 2):
import httplib

    class HTTPSConnectionV3(httplib.HTTPSConnection):
        def __init__(self, *args, **kwargs):
            httplib.HTTPSConnection.__init__(self, *args, **kwargs)

        def connect(self):
            sock = socket.create_connection((self.host, self.port), self.timeout)
            if getattr(self, '_tunnel_host', False):
                self.sock = sock
                self._tunnel()
            try:
                self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version=ssl.PROTOCOL_TLSv1)
            except ssl.SSLError:
                try:
                    self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version=ssl.PROTOCOL_SSLv3)
                except ssl.SSLError:
                    self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file, ssl_version=ssl.PROTOCOL_SSLv23)
@Baalkikhaal
Copy link

@Baalkikhaal Baalkikhaal commented Jul 20, 2016

Dear terefang,
I was getting similar error while downloading a youtube video. Thank you for your workaround. It worked for me. However I did not understand the technicality of your solution. I would be grateful if you could explain in simple terms as I am not aware of networking fundamentals.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Jul 20, 2016

Seems SSLv3 (considered insecure) works while SSLv23 (the highest protocol version that both the client and server support) not. I don't know why some networks require it.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Jul 20, 2016

Well, another cause may be broken SSL implementations. @terefang, @Baalkikhaal What's the version of operatin system, Python and OpenSSL of your device? Please also post the output of youtube-dl -v <some URL>

@terefang
Copy link

@terefang terefang commented Jul 22, 2016

ok to explain the fix:

first try handshake TLSv1 (which currently is TLS 1.0, 1.1, 1.2)
if that fails retry with SSLv3 (lets call it TLS 0.3)
if that fails retry with SSLv23 (it is not version 23 but rather SSLv3 with SSLv2 fallback, horrible out of date, ie TLS 0.3 than TLS 0.2)

that was with youtube-dl from mint 17.3/ubuntu 14.04.x

i have since upgraded to mint 18/ubuntu 16.04 which has youtube-dl 2016.02.22 which works without the fix

@ovidiugabriel
Copy link

@ovidiugabriel ovidiugabriel commented Jul 28, 2016

Hello,

I have encountered the same issue:

[debug] System config: []
[debug] User config: []
[debug] Command-line args: ['-v', <>]
[debug] Encodings: locale 'UTF-8', fs 'UTF-8', out 'UTF-8', pref: 'UTF-8'
[debug] youtube-dl version 2014.02.17
[debug] Python version 2.7.6 - Linux-3.16.0-71-lowlatency-x86_64-with-Ubuntu-14.04-trusty
[debug] Proxy map: {}
[youtube] Setting language
WARNING: unable to set language: <urlopen error [Errno 8] _ssl.c:510: EOF occurred in violation of protocol>
[youtube] : Downloading webpage
ERROR: Unable to download webpage: <urlopen error [Errno 8] _ssl.c:510: EOF occurred in violation of protocol>
File "/usr/lib/python2.7/dist-packages/youtube_dl/extractor/common.py", line 191, in _request_webpage
return self._downloader.urlopen(url_or_request)
File "/usr/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 1157, in urlopen
return self._opener.open(req)
File "/usr/lib/python2.7/urllib2.py", line 404, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 422, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 382, in _call_chain
result = func(*args)
File "/usr/lib/python2.7/dist-packages/youtube_dl/utils.py", line 572, in https_open
return self.do_open(HTTPSConnectionV3, req)
File "/usr/lib/python2.7/urllib2.py", line 1184, in do_open
raise URLError(err)

@cru6raGu
Copy link

@cru6raGu cru6raGu commented Aug 5, 2016

Thanks to @terefang. It worked.

just to help other users. I am on Ubuntu 14.04 and the utils.py is here:

/usr/lib/python2.7/dist-packages/youtube_dl/utils.py

@acd10
Copy link

@acd10 acd10 commented Oct 6, 2016

Thanks a lot @terefang. It worked!

@AbrarNitk
Copy link

@AbrarNitk AbrarNitk commented Mar 25, 2017

Upgrade it using pip

Step First(if pip is not installed)
Firstly install pip if it is not install
sudo apt-get install python-setuptools
sudo easy_install pip

Second Step(Upgrade youtube-dl)
sudo pip install --upgrade youtube-dl

I have got the same issue after applying these two steps it is working fine.

@geoffreyvanwyk
Copy link

@geoffreyvanwyk geoffreyvanwyk commented Oct 5, 2017

This issue should be closed now, because it is fixed in the latest version youtube-dl-2017.10.1. It was broken for me in version youtube-dl-2014.2.17 which came packaged with Ubuntu 14.04.

@AbrarNitk, thanks. Your steps worked.

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Oct 5, 2017

fqrouter is dead [1], socks proxy support is now built-in, and many people confirmed that the latest youtube-dl works fine, so yes, this can be closed. Thanks for the reminder!

[1] https://twitter.com/fqrouter/status/578967338046787585

@yan12125 yan12125 closed this Oct 5, 2017
@GrayXu
Copy link

@GrayXu GrayXu commented Mar 23, 2020

the same problem on clash for windows10 and the latest version of youtube-dl

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

Successfully merging a pull request may close this issue.

None yet
You can’t perform that action at this time.