[Solved] sabnzbd 1.2.0 not working

Support for the freeBSD package, created by dbrooks
Post Reply
recluce
Newbie
Newbie
Posts: 8
Joined: August 6th, 2014, 11:59 am

[Solved] sabnzbd 1.2.0 not working

Post by recluce » February 4th, 2017, 4:16 pm

I just tried to update to sabnzbd+ 1.2.0 via the ports. While building worked without any error messages or warnings, the sabnzbd service will not start thereafter. I found the following in the sabnzbd error log:

Code: Select all

Traceback (most recent call last):
  File "/usr/local/bin/SABnzbd.py", line 1791, in <module>
    main()
  File "/usr/local/bin/SABnzbd.py", line 1338, in main
    hosts = all_localhosts()
  File "/usr/local/bin/SABnzbd.py", line 499, in all_localhosts
    if item not in ips and ('::1' not in item or sabnzbd.cfg.ipv6_hosting()):
TypeError: argument of type 'int' is not iterable
System is FreeBSD 10.3-STABLE amd64 (R307003). I cannot claim to understand the error message, but I found the IPv6 reference odd, as I am not using it and it is in fact disabled on the server.

Any help would be appreciated!
Last edited by recluce on February 28th, 2017, 12:02 pm, edited 1 time in total.

User avatar
safihre
Administrator
Administrator
Posts: 2219
Joined: April 30th, 2015, 7:35 am
Location: Switzerland
Contact:

Re: sabnzbd 1.2.0 not working

Post by safihre » February 4th, 2017, 4:30 pm

Do you have https enabled?
What do you have set for sabnzbd host?

recluce
Newbie
Newbie
Posts: 8
Joined: August 6th, 2014, 11:59 am

Re: sabnzbd 1.2.0 not working

Post by recluce » February 5th, 2017, 7:40 pm

safihre wrote:Do you have https enabled?
What do you have set for sabnzbd host?
sabnzbd host is simply set to the internal IP of the server, access from outside my local network is not required or desired: 10.160.230.49

https is enabled on port 9090 and this is the related information that I saw on sabnzbd's config page (1.1.0 version):

Code: Select all

Parameters: /usr/local/bin/SABnzbd.py --daemon -f /usr/local/sabnzbd/sabnzbd.ini --pidfile /var/run/sabnzbd/sabnzbd.pid
Python: 2.7.13 (default, Dec 27 2016, 16:28:59) [GCC 4.2.1 Compatible FreeBSD Clang 3.4.1 (tags/RELEASE_34/dot1-final 208032)] [UTF-8]
OpenSSL: OpenSSL 1.0.1u-freebsd 22 Sep 2016   [TLS v1.2, TLS v1.1, TLS v1, SSL v3, SSL v2]
pyOpenSSL: 16.0.0
Two additional notes: when starting the service manually "service sabnzbd start", no error is reported to standard out, but recorded to the log. Service does not actually run at that point (as indicated by top or the "not running" message when trying to stop the service).

Let me know if there is any additional information that might help - and thank you for replying!

User avatar
sander
Release Testers
Release Testers
Posts: 6166
Joined: January 22nd, 2008, 2:22 pm

Re: sabnzbd 1.2.0 not working

Post by sander » February 6th, 2017, 2:59 am

Hi Recluce,

As your a FreeBSD user, I expect you can do this: run the code below. It's the same code as in SABnzbd.py, with a bit debugging printing.
Post the result here.

Code: Select all

import socket

sabnzbdcfgipv6 = True

def all_localhosts():
    """ Return all unique values of localhost in order of preference """
    ips = ['127.0.0.1']
    try:
        # Check whether IPv6 is available and enabled
        info = socket.getaddrinfo('::1', None)
        af, socktype, proto, _canonname, _sa = info[0]
        s = socket.socket(af, socktype, proto)
        s.close()
    except socket.error:
        return ips
    try:
        info = socket.getaddrinfo('localhost', None)
    except:
        # localhost does not resolve
        return ips
    ips = []
    print "info", info
    for item in info:
        print "item", item
        item = item[4][0]
        print "item", item
        # Only return IPv6 when enabled
        if item not in ips and ('::1' not in item or sabnzbdcfgipv6):
            ips.append(item)
        print "ips", ips
    return ips


print all_localhosts()
Example output (on my Linux laptop):

Code: Select all

$ python all_localhost.py 
info [(2, 1, 6, '', ('127.0.0.1', 0)), (2, 2, 17, '', ('127.0.0.1', 0)), (2, 3, 0, '', ('127.0.0.1', 0))]
item (2, 1, 6, '', ('127.0.0.1', 0))
ips ['127.0.0.1']
item (2, 2, 17, '', ('127.0.0.1', 0))
ips ['127.0.0.1']
item (2, 3, 0, '', ('127.0.0.1', 0))
ips ['127.0.0.1']
['127.0.0.1']


recluce
Newbie
Newbie
Posts: 8
Joined: August 6th, 2014, 11:59 am

Re: sabnzbd 1.2.0 not working

Post by recluce » February 6th, 2017, 4:27 pm

Hello Sander,

thank you for taking the time and looking into this. I ran your code (as iptest.py). Since you gave no other instructions, it was simply run from my home directory as root and with the currently installed sabnzbd+ 1.1.0_1 running. Let me know if that was wrong.

Here is the output:

Code: Select all

[email protected]:~ # ./iptest.py 
info [(28, 2, 17, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (28, 1, 6, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (28, 5, 132, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 2, 17, '', ('127.0.0.1', 0)), (2, 1, 6, '', ('127.0.0.1', 0)), (2, 5, 132, '', ('127.0.0.1', 0))]
item (28, 2, 17, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'))
item 28
Traceback (most recent call last):
  File "./iptest.py", line 35, in <module>
    print all_localhosts()
  File "./iptest.py", line 29, in all_localhosts
    if item not in ips and ('::1' not in item or sabnzbdcfgipv6):
TypeError: argument of type 'int' is not iterable
For good measure, here is the output from ifconfig (lagg0 is the active interface):

Code: Select all

[email protected]:~ # ifconfig
em0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=4219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MAGIC,VLAN_HWTSO>
	ether 00:15:17:5a:07:00
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: Ethernet autoselect (1000baseT <full-duplex>)
	status: active
em1: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=4219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MAGIC,VLAN_HWTSO>
	ether 00:15:17:5a:07:00
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: Ethernet autoselect (1000baseT <full-duplex>)
	status: active
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> metric 0 mtu 16384
	options=600003<RXCSUM,TXCSUM,RXCSUM_IPV6,TXCSUM_IPV6>
	inet6 ::1 prefixlen 128 
	inet6 fe80::1%lo0 prefixlen 64 scopeid 0x3 
	inet 127.0.0.1 netmask 0xff000000 
	nd6 options=21<PERFORMNUD,AUTO_LINKLOCAL>
lagg0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=4219b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,WOL_MAGIC,VLAN_HWTSO>
	ether 00:15:17:5a:07:00
	inet 10.160.230.49 netmask 0xffffff00 broadcast 10.160.230.255 
	nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
	media: Ethernet autoselect
	status: active
	laggproto lacp lagghash l2,l3,l4
	laggport: em0 flags=1c<ACTIVE,COLLECTING,DISTRIBUTING>
	laggport: em1 flags=1c<ACTIVE,COLLECTING,DISTRIBUTING>

User avatar
sander
Release Testers
Release Testers
Posts: 6166
Joined: January 22nd, 2008, 2:22 pm

Re: sabnzbd 1.2.0 not working

Post by sander » February 6th, 2017, 5:13 pm

For easier reading, I've put your FreeBSD output into a two-liners:

Code: Select all

>>> info = [(28, 2, 17, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (28, 1, 6, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (28, 5, 132, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 2, 17, '', ('127.0.0.1', 0)), (2, 1, 6, '', ('127.0.0.1', 0)), (2, 5, 132, '', ('127.0.0.1', 0))]
>>> for item in info:
...     print item
... 
(28, 2, 17, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'))
(28, 1, 6, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'))
(28, 5, 132, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'))
(2, 2, 17, '', ('127.0.0.1', 0))
(2, 1, 6, '', ('127.0.0.1', 0))
(2, 5, 132, '', ('127.0.0.1', 0))
So we need/expect the lines beginning with "2", but SAB also gets the lines starting with "28", and that causes the problem.

https://docs.python.org/2/library/socke ... etaddrinfo tells about socket.getaddrinfo():
The function returns a list of 5-tuples with the following structure: (family, socktype, proto, canonname, sockaddr)
sockaddr is a tuple describing a socket address, whose format depends on the returned family (a (address, port) 2-tuple for AF_INET, a (address, port, flow info, scope id) 4-tuple for AF_INET6), and is meant to be passed to the socket.connect() method.

On Linux (and Windows) Family 2 is IPv4, family 10 is IPv6, but what is 28? ... Found it on http://www.cz.freebsd.org/doc/en/books/ ... tions.html :

Code: Select all

#define	AF_UNSPEC	0		/* unspecified */
#define	AF_LOCAL	1		/* local to host (pipes, portals) */
#define	AF_UNIX		AF_LOCAL	/* backward compatibility */
#define	AF_INET		2		/* internetwork: UDP, TCP, etc. */
<snip>
#define	AF_INET6	28		/* IPv6 */
Ah, on FreeBSD 28 is AF_INET6. The "10" for IPv6 is on Linux.

Now back to your problem: if the code ignores anything else than AF_INET I think we are safe ... as long as we are in an IPv4 world.

Code: Select all

>>> import socket
>>> for item in info:
...     if item[0] == socket.AF_INET:
...             print item
... 
(2, 2, 17, '', ('127.0.0.1', 0))
(2, 1, 6, '', ('127.0.0.1', 0))
(2, 5, 132, '', ('127.0.0.1', 0))
So that works. In the next post I'll give code you should try.

User avatar
sander
Release Testers
Release Testers
Posts: 6166
Joined: January 22nd, 2008, 2:22 pm

Re: sabnzbd 1.2.0 not working

Post by sander » February 6th, 2017, 5:16 pm

With one extra if-check:

Code: Select all

import socket

sabnzbdcfgipv6 = True

def all_localhosts():
    """ Return all unique values of localhost in order of preference """
    ips = ['127.0.0.1']
    try:
        # Check whether IPv6 is available and enabled
        info = socket.getaddrinfo('::1', None)
        af, socktype, proto, _canonname, _sa = info[0]
        s = socket.socket(af, socktype, proto)
        s.close()
    except socket.error:
        return ips
    try:
        info = socket.getaddrinfo('localhost', None)
    except:
        # localhost does not resolve
        return ips
    ips = []
    print "info", info
    for item in info:
        print "item", item
        if item[0] != socket.AF_INET:
            # not IPv4
            break
        item = item[4][0]
        print "item", item
        # Only return IPv6 when enabled
        if item not in ips and ('::1' not in item or sabnzbdcfgipv6):
            ips.append(item)
        print "ips", ips
    return ips


print all_localhosts()

User avatar
sander
Release Testers
Release Testers
Posts: 6166
Joined: January 22nd, 2008, 2:22 pm

Re: sabnzbd 1.2.0 not working

Post by sander » February 6th, 2017, 5:42 pm

And please run this code on your FreeBSD:

Code: Select all

python -c "import socket; print socket.getaddrinfo('localhost', None, socket.AF_INET)"

recluce
Newbie
Newbie
Posts: 8
Joined: August 6th, 2014, 11:59 am

Re: sabnzbd 1.2.0 not working

Post by recluce » February 6th, 2017, 6:36 pm

Hello Sanders,

here is the output to your modified code:

Code: Select all

info [(28, 2, 17, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (28, 1, 6, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (28, 5, 132, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 2, 17, '', ('127.0.0.1', 0)), (2, 1, 6, '', ('127.0.0.1', 0)), (2, 5, 132, '', ('127.0.0.1', 0))]
item (28, 2, 17, '', (28, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'))
[]
And here is the output to the python command:

Code: Select all

[email protected]:~ # python2.7 -c "import socket; print socket.getaddrinfo('localhost', None, socket.AF_INET)"
[(2, 2, 17, '', ('127.0.0.1', 0)), (2, 1, 6, '', ('127.0.0.1', 0)), (2, 5, 132, '', ('127.0.0.1', 0))]

recluce
Newbie
Newbie
Posts: 8
Joined: August 6th, 2014, 11:59 am

Re: sabnzbd 1.2.0 not working

Post by recluce » February 28th, 2017, 12:02 pm

This has been fixed in sabnzbd 1.2.1, thanks!

Post Reply