Skip to content

Cannot call TorRequest twice #6

@ghost

Description

When I run


from torrequest import TorRequest


with TorRequest() as tr:
    response = tr.get('http://ipecho.net/plain')
    print ("My Original IP Address:",response.text)

    tr.reset_identity() #Reset Tor
    response= tr.get('http://ipecho.net/plain')
    print ("New Ip Address",response.text)


with TorRequest() as tr:
    tr.reset_identity() #Reset Tor
    response = tr.get('http://ipecho.net/plain')
    print ("New Ip Address",response.text)

I get the following error:

Traceback (most recent call last):
  File "main.py", line 13, in <module>
    with TorRequest() as tr:
  File "/usr/local/lib/python2.7/dist-packages/torrequest.py", line 24, in __init__
    self.ctrl.authenticate(password=password)
  File "/usr/local/lib/python2.7/dist-packages/stem/control.py", line 1100, in authenticate
    stem.connection.authenticate(self, *args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/stem/connection.py", line 534, in authenticate
    raise AuthenticationFailure('socket connection failed (%s)' % exc)
stem.connection.AuthenticationFailure: socket connection failed ([Errno 111] Connection Refused)

This is similar if I call it twice in any way, such as a while loop, for a for loop (my intent is to repeat the tor request process an infinite amount of times, while resetting the ip). How do I fix this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions