python suds and socksipy

1.6k views Asked by At

I have a little problem using suds with socks.

I have a SSH tunnel ( ssh -vD 9999 user@server), and I must send/retrieve data using suds into the tunnel.

So here is my code :

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)

But it's not working, I get from the .py :

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

And from my SSH tunnel :

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

But if instead of instantiate Client, I do juste an urllib2.urlopen('google.fr'), it's working.

So I don't know what I do wrong.

If you have an idea,

Thanks

1

There are 1 answers

0
Samuel Devlin On

this:

channel 2: open failed: connect failed: Connection refused

your ssh tunnel's dynamic proxy doesn't look like it's working. The failure looks unrelated to suds. Some folks awhile back mentioned difficulties with openssh and hostnames, having success passing ip4 addresses to ssh instead. What does your ssh invocation look like?