eclipse / paho.mqtt.python

paho.mqtt.python
Other
2.19k stars 722 forks source link

Socket error: 407: Proxy Authentication Required #863

Open henzycuong1 opened 1 week ago

henzycuong1 commented 1 week ago

code:

mqtt_client = mqtt.Client(CallbackAPIVersion.VERSION2, protocol=MQTTProtocolVersion.MQTTv5, transport='websockets')
mqtt_client.proxy_set(proxy_type=socks.HTTP, proxy_addr='116.97.15.46', proxy_port=21433, proxy_username='61mdQQwpOX', proxy_password='vZxDiS')
mqtt_client.connect("wss.***.***", 443)

error:

File "c:\Users\Four\AppData\Local\Programs\Python\Python310\lib\site-packages\paho\mqtt\client.py", line 1435, in connect
    return self.reconnect()
  File "c:\Users\Four\AppData\Local\Programs\Python\Python310\lib\site-packages\paho\mqtt\client.py", line 1598, in reconnect
    self._sock = self._create_socket()
  File "c:\Users\Four\AppData\Local\Programs\Python\Python310\lib\site-packages\paho\mqtt\client.py", line 4609, in _create_socket
    sock = self._create_socket_connection()
  File "c:\Users\Four\AppData\Local\Programs\Python\Python310\lib\site-packages\paho\mqtt\client.py", line 4638, in _create_socket_connection
    return socks.create_connection(addr, timeout=self._connect_timeout, source_address=source, **proxy)
  File "c:\Users\Four\AppData\Local\Programs\Python\Python310\lib\site-packages\socks.py", line 209, in create_connection
    raise err
  File "c:\Users\Four\AppData\Local\Programs\Python\Python310\lib\site-packages\socks.py", line 199, in create_connection
    sock.connect((remote_host, remote_port))
  File "c:\Users\Four\AppData\Local\Programs\Python\Python310\lib\site-packages\socks.py", line 47, in wrapper
    return function(*args, **kwargs)
  File "c:\Users\Four\AppData\Local\Programs\Python\Python310\lib\site-packages\socks.py", line 814, in connect
    raise GeneralProxyError("Socket error", error)
socks.GeneralProxyError: Socket error: 407: Proxy Authentication Required

proxy is still alive and uses the requests as usual

henzycuong1 commented 8 hours ago

Fixed: Change Proxy-Authorization: basic to Proxy-Authorization: Basic in socks.py line 679