dbr / tvdb_api

Simple to use interface to TheTVDB.com API in Python
The Unlicense
339 stars 63 forks source link

IPV6 - Hangs #47

Closed jwyant closed 10 years ago

jwyant commented 10 years ago

Originally ipv6 was compiled in the kernel and enabled. The runtest.py hung indefinitely on the first request. I believe urllib2 is picking ipv6 instead of ipv4 which tvdb apparently has an issue with. Is there a workaround to force urllib2 to use ipv4? When I flip ipv6 off system wide through sysctl it "Ran 47 tests in 15.326s". Running python 2.7.5 and tvdb_api 1.9. Even curl hangs indefinitely with ipv6.

thezoggy commented 10 years ago

prob an issue with your nas preferring ipv6 over ipv4 causing issues.... there is known issues with ipv6 and synology for example. on a windows box with ipv6 tvdb and runtests works fine. this has been talked about numerous times

thezoggy commented 10 years ago

http://sickbeard.com/forums/viewtopic.php?f=4&t=5299&start=30 https://github.com/SynoCommunity/spksrc/issues/304

jwyant commented 10 years ago

That would definitely fix the problem except that I'm on Gentoo Linux, not a Synology NAS. I will keep ipv6 disabled for now. I don't need it at the moment. In case you need additional information, I ran into this issue on the pip install as of 4/30/2014 (should be tvdb_api 1.9), not from sickbeard or xbmc or any other application. I can open a python shell, import the library, lookup a show, and it will hang for what seems like an indefinite amount of time.

thezoggy commented 10 years ago

jwyant, so you confirmed that turning off ipv6 fixed your problem? (does your isp offer ipv6? doing 6to4?)

see the 2nd answer: http://unix.stackexchange.com/questions/9940/convince-apt-get-not-to-use-ipv6-method

thezoggy commented 10 years ago

for kicks i tested this at work (since we use v4 and v6 here),

http://pastebin.com/raw.php?i=sTkn4Hmy

no problems found

jwyant commented 10 years ago

Alright, found another workaround instead. I re-emerged python 2.7.5 with no ipv6 (in Gentoo this is just setting -ipv6 in the use flags), and then re-enabled ipv6 in sysctl (sysctl net.ipv6.conf.enp5s0.disable_ipv6=0).

This looks to be an issue with urllib2 which you use to access thetvdb.com, not with the tvdb_api code. When urllib2 is fixed, I assume tvdb_api's ability to use ipv6 correctly will be fixed. Whatever combination of system or python settings that keep urllib2 from using ipv6 allow it to work properly.

http://pastebin.com/jfTkmhyx

More testing shows that it's just thetvdb.com that's having issues with ipv6.

curl -6 thetvdb.com - hangs forever... (or at least long enough that I want to kill it before it times out) curl -4 thetvdb.com - returns immediately.

I searched some of the support topics on thetvdb's forum, and they don't seem to care or at least push the problem back on the application developers.

thezoggy commented 10 years ago

@jwyant curl -6 thetvdb.com works instantly and just for me...

#curl -V
curl 7.30.0 (x86_64-apple-darwin13.0) libcurl/7.30.0 SecureTransport zlib/1.2.5
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smtp smtps telnet tftp 
Features: AsynchDNS GSS-Negotiate IPv6 Largefile NTLM NTLM_WB SSL libz 
#curl -v -6 thetvdb.com
* Adding handle: conn: 0x7fdb7a004000
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fdb7a004000) send_pipe: 1, recv_pipe: 0
* About to connect() to thetvdb.com port 80 (#0)
*   Trying 2400:cb00:2048:1::be5d:f051...
* Connected to thetvdb.com (2400:cb00:2048:1::be5d:f051) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.30.0
> Host: thetvdb.com
> Accept: */*
> 
< HTTP/1.1 200 OK
* Server cloudflare-nginx is not blacklisted
< Server: cloudflare-nginx
< Date: Sat, 03 May 2014 06:19:46 GMT
< Content-Type: text/html
< Transfer-Encoding: chunked
< Connection: keep-alive
< Set-Cookie: __cfduid=dfce69ecf1fa35b48e217548e1e3bf17c1399097984738; expires=Mon, 23-Dec-2019 23:50:00 GMT; path=/; domain=.thetvdb.com; HttpOnly
< X-Powered-By: PHP/5.3.10-1ubuntu3.11
< Set-Cookie: PHPSESSID=v8gfpkjged49i573d9bom60ub1; path=/
< Expires: Thu, 19 Nov 1981 08:52:00 GMT
< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
< Pragma: no-cache
< Vary: User-Agent,Accept-Encoding
< CF-RAY: 124a59449a3e0104-DFW
< 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
thezoggy commented 10 years ago

anyways looks like the problem is just that your not setup for ipv6 correctly... what is your score when you go to: http://test-ipv6.com/ I get 10/10 myself.

dbr commented 10 years ago

Closing - don't think this is anything that can be fixed in tvdb_api (some of the workarounds to force Python to use IPv4 seem.. pretty ugly), sounds like either an issue with TheTVDB.com, your connection, or a combination of the two!