HttpClient Received an unexpected EOF or 0 bytes from the transport stream
请求https链接时报错,奇怪的是pc1正常,pc2异常
Unhandled Exception: System.AggregateException: One or more errors occurred. ( Received an unexpected EOF or 0 bytes from the transport stream.) ---> System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream.
at System.Net.Security.SslStreamInternal.<FillBufferAsync>g__InternalFillBufferAsync|38_0[TReadAdapter](TReadAdapter adap, ValueTask`1 task, Int32 min, Int32 initial)
原因:大概是请求时默认了一个过时了的ssl协议
解决:指定tls 1.0或其他有效协议,参考https://stackoverflow.com/questions/25414907/authenticateasclient-system-io-ioexception-received-an-unexpected-eof-or-0-byt
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
var html = GetClientStringAsync("https://**********").Result;
Console.Write(html);
Console.ReadLine();
} public static async Task<string> GetClientStringAsync(string url, string encoding = "utf-8")
{
var result = string.Empty;
var httpClientHandler = new HttpClientHandler
{
SslProtocols = System.Security.Authentication.SslProtocols.Tls
};
HttpClient client = new HttpClient(httpClientHandler);
client.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64)");
var bytes = await client.GetByteArrayAsync(url);
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
result = Encoding.GetEncoding(encoding).GetString(bytes);
return result;
}
}
HttpClient Received an unexpected EOF or 0 bytes from the transport stream的更多相关文章
- 从传输流收到意外的 EOF 或 0 个字节
/// <summary> /// 发送POST请求 /// </summary> /// <param name="json"></pa ...
- bcp sqlcmd bulkinsert在unicode问题,Unexpected EOF encountered in BCP data-file
senario 进入sqlcmd使用:out xxx产生的数据文件,因为sqlcmd export to file 默认情况下,中国的乱码.因此,使用-u(unicode)开关 @echo off & ...
- Python学习札记(二十二) 函数式编程3 filter & SyntaxError: unexpected EOF while parsing
参考: filter Problem SyntaxError: unexpected EOF while parsing 遇到该语法错误,一般是由于 括号不匹配 问题. Note 1.filter 用 ...
- Mysql: Can not read response from server. Expected to read 4 bytes, read 0 bytes before connection was unexpectedly lost.
2019-05-28 01:53:42.762 [message remind thread-24] ERROR druid.sql.Statement - {conn-10327, stmt-320 ...
- [Fiddler] ReadResponse() failed: The server did not return a complete response for this request. Server returned 0 bytes.
待解决 [Fiddler] ReadResponse() failed: The server did not return a complete response for this request. ...
- happybase(TSocket read 0 bytes)
关于报错happybase 是使用python连接hbase的一个第三方库,目前基于thrift1 .在使用过程中经常碰到报错 TTransportException(type=4, message= ...
- gzip: stdin: unexpected end of file tar: Unexpected EOF in archive
1.问题描述: 今天解压tar包遇到这样一个问题 使用命令:tar -zxvf xxxxx.tar.gz gzip: stdin: unexpected end of filetar: Unexpe ...
- pyhive -- thrift.transport.TTransport.TTransportException: TSocket read 0 bytes
Pyhive 远程连接hive出现问题: from pyhive import hive import pandas as pd #Create Hive connection conn = hive ...
- Unexpected EOF 远程主机强迫关闭了一个现有的连接 如何处理
由于数据量的增大,调用接口的次数会增加. 当连续向目标网站发送多次request后,目标网站可能会认为是,恶意攻击. 于是会抛出requests异常. 测试代码: for i in range(200 ...
随机推荐
- 关于react router 4 的小实践
详细代码栗子:https://github.com/wayaha/react-dom-CY clone然后 npm install npm start 分割线 1.这个项目使用create-react ...
- Vue作者尤雨溪:以匠人的态度不断打磨完善Vue (图灵访谈)
访谈对象: 尤雨溪,Vue.js 创作者,Vue Technology创始人,致力于Vue的研究开发. 访谈内容: 你为何选择从事前端方面的工作? 其实,我本科读的是艺术史,研究生阶段学习Design ...
- python笔记:#007#变量
变量的基本使用 程序就是用来处理数据的,而变量就是用来存储数据的 目标 变量定义 变量的类型 变量的命名 01. 变量定义 在 Python 中,每个变量 在使用前都必须赋值,变量 赋值以后 该变量 ...
- Spring Boot 快速入门笔记
Spirng boot笔记 简介 Spring Boot是由Pivotal团队提供的全新框架,其设计目的是用来简化新Spring应用的初始搭建以及开发过程.该框架使用了特定的方式来进行配置,从而使开发 ...
- 树莓派+花生棒+leanote搭建自己的笔记服务器
背景 对于一个程序猿来说.女朋友可以(暂时)没有,但是不能没有一个很好的记笔记的应用.因为记笔记可以帮助自己积累学习提升自己.每一次回头看自己记得笔记,你都会有新的理解. 也许有人会说,用有道云啊,有 ...
- 并发库应用之八 & 循环路障CyclicBarrier应用
JDK包位置:java.util.concurrent.CyclicBarrier 一个同步辅助类,它允许一组线程互相等待,直到到达某个公共屏障点 (common barrier point).在涉及 ...
- Struts标签库详解【2】
==================================================================== 需要在head中用<s:head />标签 一.控 ...
- Mysql服务启动与关闭
启动: 在cmd中输入 net start mysql 关闭: 在cmd中输入 net stop mysql
- Windows上使用Thunderbird与GPG发送和解密公钥加密的电子邮件
作者:荒原之梦 原文链接:http://zhaokaifeng.com/?p=552 非对称加密的原理: 最先出现的加密方法是对称加密.在对称加密算法中是不区分公钥和私钥的,加密与解密使用的都是同一个 ...
- [ Java面试题 ]泛型篇
1.Java中的泛型是什么 ? 使用泛型的好处是什么? 泛型是Java SE 1.5的新特性,泛型的本质是参数化类型,也就是说所操作的数据类型被指定为一个参数. 好处: 1.类型安全,提供编译期间的类 ...