python suds和socksipy

时间:2012-02-29 14:22:45

标签: python socks

我在袜子上使用肥皂水有点问题。

我有一个SSH隧道(ssh -vD 9999 user @ server), 我必须使用suds将数据发送/检索到隧道中。

所以这是我的代码:

from suds.client import Client
import socks
import urllib2

old = urllib2.socket.socket
socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, "127.0.0.1", 9999)
socks.wrapmodule(urllib2)# Suds use urllib2
client = Client(wsdl)

但它不起作用,我来自.py:

socks.GeneralProxyError: (0, 'connection closed unexpectedly')

从我的SSH隧道:

debug1: Connection to port 9999 forwarding to socks port 0 requested.
debug1: channel 2: new [dynamic-tcpip]
channel 2: open failed: connect failed: Connection refused
debug1: channel 2: free: direct-tcpip: listening port 9999 for 127.0.0.1 port 3000, connect from 127.0.0.1 port 42219, nchannels 3

但是,如果不是实例化客户端,而是使用urllib2.urlopen('google.fr'),它正在运行。

所以我不知道自己做错了什么。

如果您有任何想法,

由于

1 个答案:

答案 0 :(得分:0)

这样:

channel 2: open failed: connect failed: Connection refused

你的ssh隧道的动态代理看起来不像它正在工作。失败看起来与肥皂水无关。有些人后来提到openssh和主机名的困难,成功将ip4地址传递给ssh。你的ssh调用是什么样的?