torpy icon indicating copy to clipboard operation
torpy copied to clipboard

TimeoutError for other port then 80

Open jrespeto opened this issue 4 years ago • 2 comments

Hi

I keep getting a timeout errors trying to connect to anything other than 80. Is there a verbose setting I can switch on?

keep getting a timeout error. TimeoutError: Could not connect to ('xxx.xxx.xxx.xxx', #####)

ip="some IP"
port = openPort
from torpy import TorClient

with TorClient() as tor:
    with tor.create_circuit(3) as circuit:
        print("Connected to Tor")
        print(dir(circuit))
        with circuit.create_stream((ip, port)) as stream:
            print(dir(stream))
            data = stream.recv(1024)
            print(data)

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/asdf/pyenv/lib/python3.9/site-packages/torpy/circuit.py", line 320, in wrapped
    return fn(self, *args, **kwargs)
  File "/home/asdf/pyenv/lib/python3.9/site-packages/torpy/circuit.py", line 599, in create_stream
    tor_stream.connect(address)
  File "/home/asdf/pyenv/lib/python3.9/site-packages/torpy/stream.py", line 270, in connect
    self._connect(address)
  File "/home/asdf/pyenv/lib/python3.9/site-packages/torpy/stream.py", line 297, in _connect
    self._wait_connected(address, self._conn_timeout)
  File "/home/asdf/pyenv/lib/python3.9/site-packages/torpy/stream.py", line 276, in _wait_connected
    raise TimeoutError('Could not connect to %r' % (address,))
TimeoutError: Could not connect to ('xxx.xxx.xxx.xxx', #####)

jrespeto avatar Feb 24 '21 20:02 jrespeto

I was able to get a test working on a VSP a few times. Like 2 in 20. I guess I'm just getting some slow/crapy tor exit nodes.

Is there a way to just request exit nodes from one country?

server

# echo "Can I get this messages" | nc -l -t -p 11111

Traceback (most recent call last): File "", line 1, in File "/home/asdf/pyenv/lib/python3.9/site-packages/torpy/circuit.py", line 320, in wrapped return fn(self, *args, **kwargs) File "/home/asdf/pyenv/lib/python3.9/site-packages/torpy/circuit.py", line 599, in create_stream tor_stream.connect(address) File "/home/asdf/pyenv/lib/python3.9/site-packages/torpy/stream.py", line 270, in connect self._connect(address) File "/home/asdf/pyenv/lib/python3.9/site-packages/torpy/stream.py", line 297, in _connect self._wait_connected(address, self._conn_timeout) File "/home/asdf/pyenv/lib/python3.9/site-packages/torpy/stream.py", line 276, in _wait_connected raise TimeoutError('Could not connect to %r' % (address,)) TimeoutError: Could not connect to ('xx.xx.xx.xx', 11111)

jrespeto avatar Feb 24 '21 21:02 jrespeto

This is happens due to some exit-nodes port restrictions. In current version torpy disregard this restrictions when choose exit-node. Can you show circuit nodes list when connection failed?

jbrown299 avatar Mar 01 '21 13:03 jbrown299