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

IPv4 only not working #13422

Closed
jaminh opened this issue Jun 18, 2017 · 3 comments
Closed

IPv4 only not working #13422

jaminh opened this issue Jun 18, 2017 · 3 comments

Comments

@jaminh
Copy link

@jaminh jaminh commented Jun 18, 2017

Please follow the guide below

  • You will be asked some questions and requested to provide some information, please read them carefully and answer honestly
  • Put an x into all the boxes [ ] relevant to your issue (like that [x])
  • Use Preview tab to see how your issue will actually look like

Make sure you are using the latest version: run youtube-dl --version and ensure your version is 2017.06.18. If it's not read this FAQ entry and update. Issues with outdated version will be rejected.

  • I've verified and I assure that I'm running youtube-dl 2017.06.18

Before submitting an issue make sure you have:

  • At least skimmed through README and most notably FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

The following sections concretize particular purposed issues, you can erase any section (the contents between triple ---) not applicable to your issue


strace -o strace.log -f youtube-dl -v --force-ipv4 https://www.youtube.com/watch?v=xLNeZogTsK8
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: [u'-v', u'--force-ipv4', u'https://www.youtube.com/watch?v=xLNeZogTsK8']
[debug] Encodings: locale UTF-8, fs UTF-8, out UTF-8, pref UTF-8
[debug] youtube-dl version 2017.06.18
[debug] Python version 2.7.9 - Linux-4.9.32-v7+-armv7l-with-debian-8.0
[debug] exe versions: none
[debug] Proxy map: {}
[youtube] xLNeZogTsK8: Downloading webpage
[youtube] xLNeZogTsK8: Downloading video info webpage
[youtube] xLNeZogTsK8: Extracting video information
[youtube] {22} signature length 42.43, html5 player vfle90bgw
[youtube] xLNeZogTsK8: Downloading player https://www.youtube.com/yts/jsbin/player-vfle90bgw/en_US/base.js
[youtube] {43} signature length 42.43, html5 player vfle90bgw
[youtube] {18} signature length 42.43, html5 player vfle90bgw
[youtube] {36} signature length 42.43, html5 player vfle90bgw
[youtube] {17} signature length 42.43, html5 player vfle90bgw
[youtube] {137} signature length 42.43, html5 player vfle90bgw
[youtube] {248} signature length 42.43, html5 player vfle90bgw
[youtube] {136} signature length 42.43, html5 player vfle90bgw
[youtube] {247} signature length 42.43, html5 player vfle90bgw
[youtube] {135} signature length 42.43, html5 player vfle90bgw
[youtube] {244} signature length 42.43, html5 player vfle90bgw
[youtube] {134} signature length 42.43, html5 player vfle90bgw
[youtube] {243} signature length 42.43, html5 player vfle90bgw
[youtube] {133} signature length 42.43, html5 player vfle90bgw
[youtube] {242} signature length 42.43, html5 player vfle90bgw
[youtube] {160} signature length 42.43, html5 player vfle90bgw
[youtube] {278} signature length 42.43, html5 player vfle90bgw
[youtube] {140} signature length 42.43, html5 player vfle90bgw
[youtube] {171} signature length 42.43, html5 player vfle90bgw
[youtube] {249} signature length 42.43, html5 player vfle90bgw
[youtube] {250} signature length 42.43, html5 player vfle90bgw
[youtube] {251} signature length 42.43, html5 player vfle90bgw
[youtube] xLNeZogTsK8: Downloading MPD manifest
[debug] Invoking downloader on u'https://r15---sn-bvvbax-nuae.googlevideo.com/videoplayback?ratebypass=yes&requiressl=yes&nh=EAE&mv=u&mime=video%2Fmp4&id=o-APtVzbm4f5KRmX_GkaYYfv2iHSmZ_Fi2im0Ojk3BrFqb&mt=1497791026&mn=sn-bvvbax-nuae&ip=***.***.***.***&sparams=dur%2Cei%2Cid%2Cip%2Cipbits%2Citag%2Clmt%2Cmime%2Cmm%2Cmn%2Cms%2Cmv%2Cnh%2Cpl%2Cratebypass%2Crequiressl%2Csource%2Cexpire&pl=23&itag=22&source=youtube&ms=au&ei=C3xGWd_CF4zsD9ziirAE&key=yt6&lmt=1470913524732603&dur=569.097&ipbits=0&expire=1497813099&mm=31&signature=9386F02D31D34A312B8171ECBD89F5155DCCA4B8.4B93BEBFC179A2B23C3ECF92DE9245582913AF49'
ERROR: unable to download video data: <urlopen error [Errno 97] Address family not supported by protocol>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 1826, in process_info
success = dl(filename, info_dict)
File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 1768, in dl
return fd.download(name, info)
File "/usr/local/lib/python2.7/dist-packages/youtube_dl/downloader/common.py", line 361, in download
return self.real_download(filename, info_dict)
File "/usr/local/lib/python2.7/dist-packages/youtube_dl/downloader/http.py", line 61, in real_download
data = self.ydl.urlopen(request)
File "/usr/local/lib/python2.7/dist-packages/youtube_dl/YoutubeDL.py", line 2129, in urlopen
return self._opener.open(req, timeout=self._socket_timeout)
File "/usr/lib/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/usr/lib/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/usr/lib/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/local/lib/python2.7/dist-packages/youtube_dl/utils.py", line 1086, in https_open
req, **kwargs)
File "/usr/lib/python2.7/urllib2.py", line 1197, in do_open
raise URLError(err)
URLError: <urlopen error [Errno 97] Address family not supported by protocol>

Description of your issue, suggested solution and other information

It seems youtube-dl is not working with IPv4 only for me. I think this is the relevant log from strace:

20417 1198 socket(PF_INET, SOCK_DGRAM|SOCK_NONBLOCK, IPPROTO_IP) = 3
20418 1198 connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("...")}, 16) = 0
20419 1198 gettimeofday({1497791502, 716987}, NULL) = 0
20420 1198 poll([{fd=3, events=POLLOUT}], 1, 0) = 1 ([{fd=3, revents=POLLOUT}])
20421 1198 sendmmsg(3, {{{msg_name(0)=NULL, msg_iov(1)=[{"\262\252\1\0\0\1\0\0\0\0\0\0\24r15---sn-bvvbax-nua"..., 54}], msg_controllen=0, msg_flags=0}, 54}, {{msg_name(0 )=NULL, msg_iov(1)=[{"f\214\1\0\0\1\0\0\0\0\0\0\24r15---sn-bvvbax-nua"..., 54}], msg_controllen=0, msg_flags=0}, 54}}, 2, MSG_NOSIGNAL) = 2
20422 1198 poll([{fd=3, events=POLLIN}], 1, 5000) = 1 ([{fd=3, revents=POLLIN}])
20423 1198 ioctl(3, FIONREAD, [103]) = 0
20424 1198 recvfrom(3, "\262\252\201\200\0\1\0\2\0\0\0\0\24r15---sn-bvvbax-nua"..., 2048, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("...")}, [16]) = 103
20425 1198 gettimeofday({1497791502, 718959}, NULL) = 0
20426 1198 poll([{fd=3, events=POLLIN}], 1, 4998) = 1 ([{fd=3, revents=POLLIN}])
20427 1198 ioctl(3, FIONREAD, [115]) = 0
20428 1198 recvfrom(3, "f\214\201\200\0\1\0\2\0\0\0\0\24r15---sn-bvvbax-nua"..., 65536, 0, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("...")}, [1 6]) = 115
20429 1198 close(3) = 0
20430 1198 socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE) = 3
20431 1198 bind(3, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 0
20432 1198 getsockname(3, {sa_family=AF_NETLINK, pid=1198, groups=00000000}, [12]) = 0
20433 1198 gettimeofday({1497791502, 719630}, NULL) = 0
20434 1198 sendto(3, "\24\0\0\0\26\0\1\3\16|FY\0\0\0\0\0\0\0\0", 20, 0, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 20
20435 1198 recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"L\0\0\0\24\0\2\0\16|FY\256\4\0\0\2\10\200\376\1\0\0\0\10\0\1\0\177\0\0\ 1"..., 4096}], msg_controllen=0, msg_flags=0}, 0) = 164
20436 1198 recvmsg(3, {msg_name(12)={sa_family=AF_NETLINK, pid=0, groups=00000000}, msg_iov(1)=[{"\24\0\0\0\3\0\2\0\16|FY\256\4\0\0\0\0\0\0", 4096}], msg_controllen=0, m sg_flags=0}, 0) = 20
20437 1198 close(3) = 0
20438 1198 socket(PF_INET, SOCK_DGRAM, IPPROTO_IP) = 3
20439 1198 connect(3, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("208.65.152.34")}, 16) = 0
20440 1198 getsockname(3, {sa_family=AF_INET, sin_port=htons(54350), sin_addr=inet_addr("192.168.0.7")}, [16]) = 0
20441 1198 close(3) = 0
20442 1198 socket(PF_INET6, SOCK_DGRAM, IPPROTO_IP) = -1 EAFNOSUPPORT (Address family not supported by protocol)
20443 1198 socket(PF_INET, SOCK_STREAM, IPPROTO_TCP) = 3
20444 1198 fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR)
20445 1198 fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
20446 1198 bind(3, {sa_family=AF_INET, sin_port=htons(0), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
20447 1198 connect(3, {sa_family=AF_INET, sin_port=htons(443), sin_addr=inet_addr("208.65.152.34")}, 16) = -1 EINPROGRESS (Operation now in progress)
20448 1198 poll([{fd=3, events=POLLOUT}], 1, 600000) = 1 ([{fd=3, revents=POLLOUT|POLLERR|POLLHUP}])
20449 1198 getsockopt(3, SOL_SOCKET, SO_ERROR, [110], [4]) = 0
20450 1198 close(3) = 0
20451 1198 socket(PF_INET6, SOCK_STREAM, IPPROTO_TCP) = -1 EAFNOSUPPORT (Address family not supported by protocol)

This is on a raspberry pi with IPv6 disabled running on a network using NAT.

@Tatsh
Copy link
Contributor

@Tatsh Tatsh commented Mar 14, 2018

Confirmed here. And also with IPv6 on, I get incredibly horrible performance but I think that is my ISP. Another reason we really need --force-ipv4 to work.

@Tatsh
Copy link
Contributor

@Tatsh Tatsh commented Mar 16, 2018

A kind of useful solution is to use a Docker image. I am using the jrottenberg/ffmpeg latest image below. Note the volumes being mounted.

docker-compose.yml:

version: '3'
services:
    youtubedl:
        volumes:
            - /etc/resolv.conf:/etc/resolv.conf:ro
            - /sys/fs/cgroup:/sys/fs/cgroup:ro
            - ~/.ytch-cookies.txt:/root/.ytch-cookies.txt
            - ~/.netrc-youtube:/root/.netrc
            - ~/dev/youtube-dl:/youtube-dl
            - ~/move/ytdl:/ytdl
            - ~/.config/youtube-dl:/root/.config/youtube-dl
        image: jrottenberg/ffmpeg
        entrypoint: /youtube-dl/ep.sh

The ep.sh is this (can be made into separate images with a proper Dockerfile):

#!/usr/bin/env bash
set -eu
apt-get update
apt-get install -y python-pip atomicparsley aria2
cd /youtube-dl
pip install -e .
chown root. ~/.netrc
cat

Once you have this, docker-compose -d and then you can run youtube-dl: docker-compose exec -T youtubedl youtube-dl.

You will need to start off with a Pi-compatible image. If you plan on using ffmpeg, I'd recommend building ffmpeg from source for the Pi so you can strip it down to your needs. And for AtomicParsley you'll need to build it too (and I am not certain it's completely portable).

@Tatsh
Copy link
Contributor

@Tatsh Tatsh commented Mar 16, 2018

Also disabling IPv6 completely with the kernel is definitely the simplest solution (as root):

echo net.ipv6.conf.all.disable_ipv6=1 >> /etc/sysctl.conf
sysctl -w net.ipv6.conf.all.disable_ipv6=1
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
2 participants
You can’t perform that action at this time.