PySocks
PySocks copied to clipboard
All offered SOCKS5 authentication methods were rejected
Hi! I've used this Docker image to setup a Socks5 proxy on my remote server https://hub.docker.com/r/serjs/go-socks5-proxy/ and it seem to be working:
$ curl --socks5-hostname 195.201.21.5:1080 --proxy-user argon:rknshouldnotpass http://ifcfg.co
195.201.21.5
But your library fails to connect:
In [1]: import socks
...: s = socks.socksocket()
...: s.set_proxy(socks.SOCKS5, '195.201.21.5', 1080, 'argon', 'rknshouldnotpass')
...: s.connect(("www.sourceforge.net", 80))
...:
---------------------------------------------------------------------------
SOCKS5AuthError Traceback (most recent call last)
~/.Envs/mess/lib/python3.6/site-packages/socks.py in connect(self, dest_pair)
850 negotiate = self._proxy_negotiators[proxy_type]
--> 851 negotiate(self, dest_addr, dest_port)
852 except socket.error as error:
~/.Envs/mess/lib/python3.6/site-packages/socks.py in _negotiate_SOCKS5(self, *dest_addr)
496 self.proxy_peername, self.proxy_sockname = self._SOCKS5_request(
--> 497 self, CONNECT, dest_addr)
498
~/.Envs/mess/lib/python3.6/site-packages/socks.py in _SOCKS5_request(self, conn, cmd, dst)
556 raise SOCKS5AuthError(
--> 557 "All offered SOCKS5 authentication methods were"
558 " rejected")
SOCKS5AuthError: All offered SOCKS5 authentication methods were rejected
During handling of the above exception, another exception occurred:
GeneralProxyError Traceback (most recent call last)
<ipython-input-1-e3515a859c28> in <module>()
2 s = socks.socksocket()
3 s.set_proxy(socks.SOCKS5, '195.201.21.5', 1080, 'argon', 'rknshouldnotpass')
----> 4 s.connect(("www.sourceforge.net", 80))
~/.Envs/mess/lib/python3.6/site-packages/socks.py in wrapper(*args, **kwargs)
98 if _is_blocking == 0:
99 self.setblocking(True)
--> 100 return function(*args, **kwargs)
101 except Exception as e:
102 raise
~/.Envs/mess/lib/python3.6/site-packages/socks.py in connect(self, dest_pair)
853 # Wrap socket errors
854 self.close()
--> 855 raise GeneralProxyError("Socket error", error)
856 except ProxyError:
857 # Protocol error while negotiating with proxy
GeneralProxyError: Socket error: All offered SOCKS5 authentication methods were rejected
Could you please tell me what am I missing here?
Thanks!
Have you solved this problem?
@xucheng2008 nope, I believe I gave up on this
The solution is simple. Just replace "s.set_proxy(socks.SOCKS5, '195.201.21.5', 1080, 'argon', 'rknshouldnotpass')" with "s.set_proxy(socks.SOCKS5, '195.201.21.5', 1080, username='argon', password='rknshouldnotpass')".. That worked for me.!
In my case, socks5 configure didn't have proper setting -- after permit all from intended origin, error has gone :)