首页 > 其他分享 >Caused by ProxyError('Unable to connect to proxy', SSLError(SSLEOFError(8, '[SSL: UNE

Caused by ProxyError('Unable to connect to proxy', SSLError(SSLEOFError(8, '[SSL: UNE

时间:2024-12-17 12:00:09浏览次数:4  
标签:UNEXPECTED protocol EOF server SSL connection proxy http requests

背景

有个网站开了代理,浏览器可以访问,但是命令行ping不通,telnet不通,python requests请求报上述错误

解决方案

配置代理,改成http请求

url = "http://m.zhibo8.com/news/web/zuqiu/2024-12-02/match1437755date2024vnative.htm"  # 替换为实际的网页链接

proxies = {
    'http': 'http://127.0.0.1:7890',
    # 'https': 'https://127.0.0.1:7890'
}

# 发送请求并获取网页内容
response = requests.get(url, proxies=proxies, verify=False)

参考

This error is related to an issue with SSL while attempting to connect to a server through a proxy. Here's a breakdown of the problem and possible solutions:

Problem Details

  1. ProxyError: The application was unable to establish a connection to the proxy server.
  2. SSLError: The SSL/TLS handshake failed.
  3. SSLEOFError: The server abruptly closed the connection during the handshake, which is against the SSL protocol.

Common Causes

  1. Incorrect Proxy Configuration: The proxy settings (URL, port, username/password) might be incorrect.
  2. Incompatible SSL/TLS Version: The server or proxy might require a specific SSL/TLS version that is not supported or configured.
  3. Firewall or Network Issues: A firewall might be blocking the connection.
  4. Outdated SSL Certificates: The SSL certificates used by the client or proxy might be invalid or expired.
  5. Server-Side Issues: The proxy or server could be misconfigured or experiencing downtime.

Solutions

1. Verify Proxy Settings

  • Double-check the proxy URL, port, and authentication credentials.
  • Ensure the proxy server is reachable and functional by testing with tools like curl or ping.

2. Update SSL/TLS Configuration

  • Explicitly configure your application to use a compatible SSL/TLS version.
  • If you’re using Python’s requests library, you can set the SSL/TLS version using a Session or a custom adapter.

3. Check Network and Firewall

  • Ensure no firewalls or antivirus programs are blocking the connection.
  • Use tools like traceroute or telnet to test the connection to the proxy server.

4. Update or Reinstall SSL Certificates

  • Update your system’s CA certificates.
  • If you’re working in a custom environment, use trusted certificate authorities.

5. Bypass Proxy (Temporary Test)

  • Temporarily disable the proxy and test if the connection works directly.

6. Debugging Code Snippet

If you're using Python's requests, consider this code to bypass or debug:

import requests

proxies = {
    "http": "http://proxy-server:port",
    "https": "http://proxy-server:port",
}

try:
    response = requests.get("https://example.com", proxies=proxies, timeout=10)
    print(response.status_code)
except requests.exceptions.ProxyError as e:
    print(f"Proxy Error: {e}")
except requests.exceptions.SSLError as e:
    print(f"SSL Error: {e}")
except Exception as e:
    print(f"General Error: {e}")

7. Increase Logging

  • Enable verbose logging for SSL and networking (e.g., requests or your network library) to capture more details.

If the issue persists, provide more details about your environment, such as the programming language, library, and proxy setup, for more tailored assistance!

标签:UNEXPECTED,protocol,EOF,server,SSL,connection,proxy,http,requests
From: https://www.cnblogs.com/lijiale/p/18612021

相关文章

  • Java中Integer.parseInt和Integer.valueOf,你还在傻傻分不清吗?
    Integer.parseInt和Integer.valueOf一、源码分析二、结论三、扩展在Java的Integer类中,有Integer.valueOf(Strings)和Integer.parseInt(Strings)两个静态方法,他们都能够将字符串转换为整型,他们到底有什么区别呢?一、源码分析Integer.parseInt(Strings)的源码:pub......
  • Windows Server 2022 DHCP 服务器 是一种网络服务,属于 动态主机配置协议(DHCP, Dynamic
    WindowsServer2022DHCP服务器是一种网络服务,属于动态主机配置协议(DHCP,DynamicHostConfigurationProtocol)实现的一部分,用于自动为网络中的计算机和设备分配IP地址和其他网络配置信息,如子网掩码、默认网关和DNS服务器等。功能和作用:自动化IP地址分配:DHCP服......
  • Caused by_ net.sf.jsqlparser.parser.ParseException_ Encountered unexpected token
    问题:在xml里写完sql语句进行测试时抛出ParseException异常,如下:selectbasic.idas'id',frombasic_infobasic<iftest="request.behaveType!=null">innerjoinapply_infoapplyonapply.basic_info_id=basic.id&......
  • Git之git push报错protocol error: bad line length 8192怎么处理
    故障现象gitpull报错$gitpushCountingobjects:40,done.Deltacompressionusingupto32threads.Compressingobjects:100%(38/38),done.fatal:protocolerror:badlinelength819247.18MiB/sfatal:sha1file'<stdout>'writeerror:Bro......
  • 达梦DM.Microsoft.EntityFreameworkCore查询报错invalid cast from DateTime to DateT
    1.问题达梦dotnetefcore的驱动DM.Microsoft.EntityFreameworkCore。如果实体中存在DateTimeOffset类型字段时,查询报错:invalidcastfromDateTimetoDateTimeOffset。Invalidcastfrom'System.DateTime'to'System.DateTimeOffset'System.Convert.DefaultToType(Sy......
  • Java基础系列-instanceof关键字
    作者简介:大家好,我是码炫码哥,前中兴通讯、美团架构师,现任某互联网公司CTO,兼职码炫课堂主讲源码系列专题代表作:《jdk源码&多线程&高并发》,《深入tomcat源码解析》,《深入netty源码解析》,《深入dubbo源码解析》,《深入springboot源码解析》,《深入spring源码解析》,《深入redis源码......
  • 如何用source和source结合cat << EOF 和EOF )实现template.txt模板文件变量的替换
    使用source和cat<<EOF来实现template.txt模板文件变量的替换,你可以按照以下步骤操作:创建 config.env 文件:包含变量定义。创建 template.txt 文件:包含模板内容。编写一个脚本:使用 source 导入变量,然后使用 cat<<EOF 和 EOF 读取模板文件并替换变量。下面......
  • C#中的DateTime、DateTimeOffset和TimeSpan(链接)
    下面的微软官方文档,介绍了C#中的DateTime:DateTimeStructSystem.DateTimestruct其中这里有提到,DateTime的精度为100纳秒:Timevaluesaremeasuredin100-nanosecondunitscalledticks.DateTime.TicksProperty属性可以返回DateTime代表的100纳秒数。而DateTime(Int64)......
  • JS-7 typeof 运算符
    数值:number、字符串:string、布尔值:bookan、对象:objectJavaScript有三种方法,可以确定一个值到底是什么类型,而我们现在需要接触到的就是typeof1、数值返回numbertypeo123//"number"2、字符串返回stringtypeof'123'//"string"3、布尔值返回booleantypeof......
  • MCP(Model Context Protocol)模型上下文协议 实战篇
    2024年11月底,Anthropic公司发布了全新的MCP(ModelContextProtocol)协议,即模型上下文协议。该协议作为一种开放标准,旨在实现大型语言模型(LLM)应用程序与外部数据源和工具之间的无缝集成。无论是在开发AI驱动的集成开发环境(IDE)、增强聊天界面,还是创建自定义AI工作流程,MCP都提供了......