stem : GETINFO request contained unrecognized keywords
The following code snippet worked fine so far:
import time
import functools
from stem import ORStatus, ORClosureReason
from stem.control import EventType, Controller
def main():
print "Tracking requests for tor exits. Press 'enter' to end."
print
with Controller.from_port() as controller:
controller.authenticate()
orconn_listener = functools.partial(orconn_event, controller)
controller.add_event_listener(orconn_listener, EventType.ORCONN)
raw_input() # wait for user to press enter
def orconn_event(controller, event):
if event.status == ORStatus.CLOSED and event.reason == ORClosureReason.IOERROR:
fingerprint = event.endpoint_fingerprint
relay = controller.get_network_status(fingerprint)
print " %i %s %15s %5i %s %s %s" % (event.arrived_at, time.ctime(event.arrived_at), relay.address, relay.or_port, relay.fingerprint, controller.get_info("ip-to-country/%s" % relay.address, 'unknown'), relay.nickname)
if __name__ == '__main__':
main()
but sometimes I do get:
tfoerste@tor-relay ~ $ sudo python /home/tfoerste/err.py
Tracking requests for tor exits. Press 'enter' to end.
1417547699 Tue Dec 2 20:14:59 2014 81.169.152.100 9001 A784839B4201C1C6714D441D3C0122E76BD6FF9E de 0x7ffd
Exception in thread Event Notifier:
Traceback (most recent call last):
File "/usr/lib64/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/usr/lib64/python2.7/threading.py", line 763, in run
self.__target(*self.__args, **self.__kwargs)
File "/usr/lib64/python2.7/site-packages/stem/control.py", line 775, in _event_loop
self._handle_event(event_message)
File "/usr/lib64/python2.7/site-packages/stem/control.py", line 2810, in _handle_event
listener(event_message)
File "/home/tfoerste/err.py", line 25, in orconn_event
relay = controller.get_network_status(fingerprint)
File "/usr/lib64/python2.7/site-packages/stem/control.py", line 1670, in get_network_status
raise exc
InvalidArguments: GETINFO request contained unrecognized keywords: ns/id/5AC9C5AA75BA1F18D8459B326B4B8111A856D290
^CTraceback (most recent call last):
File "/home/tfoerste/err.py", line 30, in <module>
main()
File "/home/tfoerste/err.py", line 17, in main
raw_input() # wait for user to press enter
KeyboardInterrupt
I'm using net-libs/stem-1.2.2_p20141018 at a hardened Gentoo 64 bit with python 2.7