当前位置:   article > 正文

python request post时候报错解决requests.exceptions.ProxyError: HTTPSConnectionPool(host=‘open.iot.10086.cn_python 如何捕获 requests.exceptions.proxyerror: 错误

python 如何捕获 requests.exceptions.proxyerror: 错误

报错信息:

Traceback (most recent call last):
  File "C:\Program Files (x86)\software\python_wxw\python38\Lib\site-packages\urllib3\connectionpool.py", line 711, in urlopen
    self._prepare_proxy(conn)
  File "C:\Program Files (x86)\software\python_wxw\python38\Lib\site-packages\urllib3\connectionpool.py", line 1007, in _prepare_proxy
    conn.connect()
  File "C:\Program Files (x86)\software\python_wxw\python38\Lib\site-packages\urllib3\connection.py", line 369, in connect
    self.sock = conn = self._connect_tls_proxy(hostname, conn)
  File "C:\Program Files (x86)\software\python_wxw\python38\Lib\site-packages\urllib3\connection.py", line 504, in _connect_tls_proxy
    socket = ssl_wrap_socket(
  File "C:\Program Files (x86)\software\python_wxw\python38\Lib\site-packages\urllib3\util\ssl_.py", line 453, in ssl_wrap_socket
    ssl_sock = _ssl_wrap_socket_impl(sock, context, tls_in_tls)
  File "C:\Program Files (x86)\software\python_wxw\python38\Lib\site-packages\urllib3\util\ssl_.py", line 495, in _ssl_wrap_socket_impl
    return ssl_context.wrap_socket(sock)
  File "C:\Program Files (x86)\software\python_wxw\python38\lib\ssl.py", line 500, in wrap_socket
    return self.sslsocket_class._create(
  File "C:\Program Files (x86)\software\python_wxw\python38\lib\ssl.py", line 1040, in _create
    self.do_handshake()
  File "C:\Program Files (x86)\software\python_wxw\python38\lib\ssl.py", line 1309, in do_handshake
    self._sslobj.do_handshake()
OSError: [Errno 0] Error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Program Files (x86)\software\python_wxw\python38\Lib\site-packages\requests\adapters.py", line 486, in send
    resp = conn.urlopen(
  File "C:\Program Files (x86)\software\python_wxw\python38\Lib\site-packages\urllib3\connectionpool.py", line 798, in urlopen
    retries = retries.increment(
  File "C:\Program Files (x86)\software\python_wxw\python38\Lib\site-packages\urllib3\util\retry.py", line 592, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='open.iot.10086.cn', port=443): Max retries exceeded with url: /fuse/http/device/thing/property/post?topic=$sys/fs1W2mxU41/licheepi4a/thing/property/post&protocol=http (Caused by ProxyError('Cannot connect to proxy.', OSError(0, 'Error')))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/wuboy/PycharmProjects/my_project/onent_wxw/main.py", line 23, in <module>
    response = requests.request("POST", url, headers=headers, data=payload)
  File "C:\Program Files (x86)\software\python_wxw\python38\Lib\site-packages\requests\api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
  File "C:\Program Files (x86)\software\python_wxw\python38\Lib\site-packages\requests\sessions.py", line 587, in request
    resp = self.send(prep, **send_kwargs)
  File "C:\Program Files (x86)\software\python_wxw\python38\Lib\site-packages\requests\sessions.py", line 701, in send
    r = adapter.send(request, **kwargs)
  File "C:\Program Files (x86)\software\python_wxw\python38\Lib\site-packages\requests\adapters.py", line 513, in send
    raise ProxyError(e, request=request)
requests.exceptions.ProxyError: HTTPSConnectionPool(host='open.iot.10086.cn', port=443): Max retries exceeded with url: /fuse/http/device/thing/property/post?topic=$sys/fs1W2mxU41/licheepi4a/thing/property/post&protocol=http (Caused by ProxyError('Cannot connect to proxy.', OSError(0, 'Error')))

Process finished with exit code 1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48

解决方法:
关闭梯子就行

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/175629
推荐阅读
相关标签
  

闽ICP备14008679号