pythonwebsocketproxysockspysocks

Python connection to IRC server with proxy


I'm trying to connect to IRC server with socks proxy for testing purposes. Socks proxy is alive at the moment of writing this post. I've checked it with Proxy checker and even connected to the IRC server using this proxy address and port in mIRC options, everything worked fine.

However I fail to connect to IRC server via Python:

import socks
import time

proxy_type = socks.PROXY_TYPE_SOCKS4
proxy = '192.111.135.17'
port =  18302

network = "irc.icqchat.net"
port = 6667

irc = socks.socksocket()
irc.setproxy(proxy_type, proxy, port)

irc.connect((network, port))    

print (irc.recv ( 4096 ))
irc.send(bytes(  'NICK  test_connection \r\n' , "UTF-8"))
irc.send(bytes(  'USER botty botty botty :Sup\r\n' , "UTF-8"))
irc.send(bytes(  'JOIN  #testing \r\n' , "UTF-8"))
time.sleep(4)

the proxy connection either refuses to work (connects me directly with my real IP) or returns me mistake: socks.ProxyConnectionError: Error connecting to SOCKS4 proxy 192.111.135.17:6667: [WinError 10060] the attempt to establish the connection was unsuccessful, because From another computer, the desired response was not received for the required time, or the already installed connection was torn due to the incorrect response of the already connected computer

I've checked it with different SOCK4 and SOCKS5 proxies, still no result. Is there a mistake in my code sample or is it a known issue of socks library?


Solution

  • That's a network error, meaning that your computer, or maybe python, is unable to connect to the proxy server. Now, since you checked the proxies on your computer, I'm assuming they work, You could try the library sockslib, which I created as a replacement to pysocks, as that library has not been updated or maintained for quite some time.