请求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的更多相关文章

  1. 从传输流收到意外的 EOF 或 0 个字节

    /// <summary> /// 发送POST请求 /// </summary> /// <param name="json"></pa ...

  2. bcp sqlcmd bulkinsert在unicode问题,Unexpected EOF encountered in BCP data-file

    senario 进入sqlcmd使用:out xxx产生的数据文件,因为sqlcmd export to file 默认情况下,中国的乱码.因此,使用-u(unicode)开关 @echo off & ...

  3. Python学习札记(二十二) 函数式编程3 filter & SyntaxError: unexpected EOF while parsing

    参考: filter Problem SyntaxError: unexpected EOF while parsing 遇到该语法错误,一般是由于 括号不匹配 问题. Note 1.filter 用 ...

  4. 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 ...

  5. [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. ...

  6. happybase(TSocket read 0 bytes)

    关于报错happybase 是使用python连接hbase的一个第三方库,目前基于thrift1 .在使用过程中经常碰到报错 TTransportException(type=4, message= ...

  7. 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 ...

  8. pyhive -- thrift.transport.TTransport.TTransportException: TSocket read 0 bytes

    Pyhive 远程连接hive出现问题: from pyhive import hive import pandas as pd #Create Hive connection conn = hive ...

  9. Unexpected EOF 远程主机强迫关闭了一个现有的连接 如何处理

    由于数据量的增大,调用接口的次数会增加. 当连续向目标网站发送多次request后,目标网站可能会认为是,恶意攻击. 于是会抛出requests异常. 测试代码: for i in range(200 ...

随机推荐

  1. 【数据可视化之Flask】快速设计和部署Flask网站

    Flask是Python应用于WEB开发的第三方开源框架,以设计简单高效著称.我也尝试过Django,相对于Flask显得更加全面同样也更加笨重,并且我也不需要它的后台管理功能,因此选择了Flask作 ...

  2. SSRS 数据源访问Cube 无法创建订阅的解决方法

    SSRS Report 的数据源可以直接放问SSAS 的Cube. 当报表的数据源设置成下图: 这样设置后,report 能够正常访问 Cube 并打开Report. 但是,如果我们需要添加数据驱动的 ...

  3. MariaDB/MySQL备份和恢复(三):xtrabackup用法和原理详述

    本文目录: 1.安装xtrabackup 2.备份锁 3.xtrabackup备份原理说明 3.1 备份过程(backup阶段) 3.2 准备过程(preparing阶段) 3.3 恢复过程(copy ...

  4. Python进阶开发之网络编程,socket实现在线聊天机器人

    系列文章 √第一章 元类编程,已完成 ; √第二章 网络编程,已完成 ; 本文目录 什么是socket?创建socket客户端创建socket服务端socket工作流程图解socket公共函数汇总实战 ...

  5. Java程序基础编程基础

    1.在屏幕上输出"你好" //Programmer name Helloword.javapublic class Helloword { public static void m ...

  6. hdu-2683 TCE-frep number system---完全数+二项展开式

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=2683 题目大意: g(n)是n的因子和 两种操作: A a b 查询a b区间有多少个n满足上式. ...

  7. C Primer Plus 第8章 字符输入/输出和验证输入 编程练习

    1. #include <stdio.h> int main(){ char ch; int ct = 0; while ((ch=getchar()) != EOF) ct++; pri ...

  8. 语音识别中的CTC算法的基本原理解释

    欢迎大家前往腾讯云+社区,获取更多腾讯海量技术实践干货哦~ 本文作者:罗冬日 目前主流的语音识别都大致分为特征提取,声学模型,语音模型几个部分.目前结合神经网络的端到端的声学模型训练方法主要CTC和基 ...

  9. Java多线程-概念与原理

    一.操作系统中线程和进程的概念 现在的操作系统是多任务操作系统.多线程是实现多任务的一种方式. 进程是指一个内存中运行的应用程序,每个进程都有自己独立的一块内存空间,一个进程中可以启动多个线程.比如在 ...

  10. 【原】fetch跨域请求附带cookie(credentials)

    HTTP访问控制 https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Access_control_CORS 解决跨域的方式有很多种,本文介绍" ...