通过 Tor 连接时,SocksiP 失败

Posted

技术标签:

【中文标题】通过 Tor 连接时,SocksiP 失败【英文标题】:SocksiPy fails when connecting throug Tor 【发布时间】:2014-01-26 00:06:01 【问题描述】:

尝试了以下3种方法来控制Tor:

使用 TorCtl/urllib2:Python script Exception with Tor 使用 socks/httplib:http://www.youtube.com/watch?v=KDsmVH7eJCs 使用 socks/urllib2:Python urllib over TOR?

每个都失败并出现相同的错误(试图使其尽可能清晰):

Traceback (most recent call last):

File "tor.py", line 26, in <module>
  print(urllib2.urlopen("http://www.ifconfig.me/ip").read())

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py"
line 127, in urlopen
  return _opener.open(url, data, timeout)
line 404, in open
  response = self._open(req, data)
line 422, in _open
  '_open', req)
line 382, in _call_chain
  result = func(*args)
line 1214, in http_open
  return self.do_open(httplib.HTTPConnection, req)
line 1181, in do_open
  h.request(req.get_method(), req.get_selector(), req.data, headers)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py"
line 973, in request
  self._send_request(method, url, body, headers)
line 1007, in _send_request
  self.endheaders(body)
line 969, in endheaders
  self._send_output(message_body)
line 829, in _send_output
  self.send(msg)
line 791, in send
  self.connect()
line 772, in connect
  self.timeout, self.source_address)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py"
line 562, in create_connection
  sock.connect(sa)

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/SocksiPy_branch-1.01-py2.7.egg/socks.py"
line 392, in connect
  self.__negotiatesocks5(destpair[0],destpair[1])
line 199, in __negotiatesocks5
  self.sendall("\x05\x01\x00")
line 165, in sendall
  socket.socket.sendall(self, bytes)

...最后一个错误重复了很多次,然后...

File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/SocksiPy_branch-1.01-py2.7.egg/socks.py", line 163, in sendall
  if 'encode' in dir(bytes):
RuntimeError: maximum recursion depth exceeded while calling a Python object

有人知道它的出处吗?

【问题讨论】:

没人知道那里发生了什么? 【参考方案1】:

对我来说,使用 pip 安装 socksipy-branch 实际上失败

但是,在我将 socks.py 从http://socksipy.sourceforge.net/ 直接下载到我的工作目录后,它工作正常。

【讨论】:

【参考方案2】:

看起来您正在使用 SocksiPy 库。我遇到了同样的问题,并通过直接从https://code.google.com/p/socksipy-branch/ 再次安装此库来解决它。我第一次通过pip 安装它。

【讨论】:

刚刚尝试通过 setup.py 直接从 tar.gz 安装它,但它仍然以同样的方式崩溃。

以上是关于通过 Tor 连接时,SocksiP 失败的主要内容,如果未能解决你的问题,请参考以下文章

通过 TOR swift 路由 WKWebView

引入整行数据(通过气流)时,Google GCS 到 BIGQUERY 失败

为啥tor总是连接不到tor网络?

tor和tor从抽象基类通过其他抽象类继承到具体

通过 SSMS 连接时 SQL Server 2012 集成服务失败

使用Python通过Tor(SOCKS5)发送UDP请求