I am unable to use the function get_ports()
with stem
. It says
# python get_ports.py OR
[...]
File "/usr/local/lib/python2.7/dist-packages/stem/socket.py", line 126, in send
raise stem.SocketClosed()
get_ports.py
contains the following:
import stem
from stem.control import Controller
import sys
with Controller.from_port(port = 9051) as controller:
controller.authenticate() # provide the password here if you set one
print controller.get_ports('OR')
I am certain my control port is open. My torrc
has the following non-commented lines:
CookieAuthentication 1
ControlPort 9051
StrictNodes 1
Why can't I connect to my control port and how to execute the get_ports()
function properly?
PS (full output)
# python get_ports.py [git][stem/controller][master]
Traceback (most recent call last):
File "get_ports.py", line 11, in <module>
print controller.get_ports('OR')
File "/usr/local/lib/python2.7/dist-packages/stem/control.py", line 454, in wrapped
return func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/stem/control.py", line 1302, in get_ports
return [port for (addr, port) in self.get_listeners(listener_type) if addr == '127.0.0.1']
File "/usr/local/lib/python2.7/dist-packages/stem/control.py", line 454, in wrapped
return func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/stem/control.py", line 1334, in get_listeners
for listener in self.get_info(query).split():
File "/usr/local/lib/python2.7/dist-packages/stem/control.py", line 454, in wrapped
return func(self, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/stem/control.py", line 1162, in get_info
response = self.msg('GETINFO %s' % ' '.join(params))
File "/usr/local/lib/python2.7/dist-packages/stem/control.py", line 627, in msg
self._socket.send(message)
File "/usr/local/lib/python2.7/dist-packages/stem/socket.py", line 126, in send
raise stem.SocketClosed()
stem.SocketClosed