The underlying connection was closed: An unexpected error occurred on a send
操作系统是Windows Server 2003 x64 SP2,使用Framework 4.0,在使用WebClient访问某些特定的HTTPS站点时,会引发异常:
Unhandled Exception: System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a send. ---> System.IO.IOException: Authentication failed because the remote party has closed the transport stream.
at System.Net.Security.SslState.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ForceAuthentication(Boolean receiveFirst, Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Net.TlsStream.ProcessAuthentication(LazyAsyncResult result)
at System.Net.TlsStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.PooledStream.Write(Byte[] buffer, Int32 offset, Int32 size)
at System.Net.ConnectStream.WriteHeaders(Boolean async)
--- End of inner exception stack trace ---
The underlying connection was closed: An unexpected error occured on a send.
基础连接已关闭,发送时发生错误
从信息上看是ssl认证失败,此错误并不是所有https站点都出现,另外报错的站点,用浏览器或是wget一类的工具访问都正常。挑了一个报异常的网站,查看一下连接信息(用的firefox):
使用了比较新的TLS1.2,开始怀疑操作系统不支持,于是开始翻微软网站,找到一个页面:
确认了Server 2003确实不支持,需要打个hotfix,之后再尝试就一切正常了。有遇到相同问题的同学可以参考一下。
The underlying connection was closed: An unexpected error occurred on a send的更多相关文章
- 微信接口问题(The underlying connection was closed: An unexpected error occurred on a send)
突然在调用微信接口是报:The underlying connection was closed: An unexpected error occurred on a send错误,跟踪了半天,是因为 ...
- Json Post到 https的坑 - the underlying connection was closed an unexpected error occurred on a send(远程服务器未知错误导致关闭)
最近做了一个安装包,安装包会弹出dotnet的 窗体,这个安装包会去调用https的一个api.用测试程序测试窗体都是好的.一旦打入安装包后,就报错.研究了半天,原来是https惹的祸 解决方案: . ...
- The underlying connection was closed: An unexpected error occurred on a receive
解决方法 webRequest.KeepAlive = false; ServicePointManager.ServerCertificateValidationCallback += (s, ce ...
- The underlying connection was closed: An unexpected error occurred on a rece
服务器问题,在后台访问外网了,特别是https的网站,容易出这个问题. 修改服务器配置,或修改代码解决.
- Web Server 使用WebClient 发送https请求 The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel
使用WebClient 发送https请求 使用WebClient发送请求时,并且是以https协议: WebClient webClient = new WebClient(); string re ...
- EX:The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
EX:The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secu ...
- [WebException: The underlying connection was closed: The message length limit was exceeded.]解决方法
[WebException: The underlying connection was closed: The message length limit was exceeded.] Syste ...
- [bug]The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
写在前面 在模拟请求的时候,如果url为https的,会报这个错误.大概错误就是:基础连接已关闭:无法建立信任关系的SSL / TLS的安全通道. The underlying connection ...
- windows xp .net framework 4.0 HttpWebRequest 报The underlying connection was closed,基础连接已关闭
windows xp .net framework 4.0 HttpWebRequest 报The underlying connection was closed,基础连接已关闭,错误的解决方法 在 ...
随机推荐
- C# 结构与类
结构是一种可以包含数据成员和方法成员的值类型数据结构.为结构分配数据时不需要从托管堆中分配内存,结构类型的变量直接包含了该结构的数据.结构中可以包含构造函数,常量,字段方法,属性,运算符,事件和嵌套类 ...
- verdaccio启动命令
1.启动项目 根目录下 verdaccio 2.npm 源管理 nrm 下载 3.nrm 源列表 nrm ls 4.nrm 源增加 nrm add verdaccio http://localhost ...
- [Go] vscode配置Go环境
首先要先把环境变量配置好,配置好环境变量打开go文件的时候,会自动提示需要安装的扩展在/root/.profile和/home/当前用户/.profile都加上 export GOPATH=/var/ ...
- 11.Java基础_IDEA常用快捷键
/* 内容辅助键: psvm 回车 : 快速生成main方法: sout 回车 : 快速生成输出代码 Ctrl+Alt+Space : 内容提示,代码补全 快捷键: 注释: 单行: 选中代码, Ctr ...
- python函数加括号于不加括号的区别
一.不带括号时,调用的是这个函数本身 ,是整个函数体,是一个函数对象,不须等该函数执行完成二.带括号(参数或者无参),调用的是函数的执行结果,须等该函数执行完成的结果 def test(a): ret ...
- Maven中使用tomcat:run出现错误org.eclipse.jdt.internal.compiler.classfmt.ClassFormatException
配置是正常的.查阅资料以后说是jdk版本什么的问题.多方修改没有任何改观.换一个思路去查询tomcat:run怎么运行. 是因为他还是沿用了上一次的tomcat插件(默认是6)所以运行的时候使用 to ...
- python3.5.3rc1学习四:类
class calculator: def add(x,y): return x + y print(added) def sub(x,y): return x - y print(sub) def ...
- lua 7 运算符
转自:http://www.runoob.com/lua/lua-miscellaneous-operator.html Lua提供了以下几种运算符类型: 算术运算符 关系运算符 逻辑运算符 其他运算 ...
- LG2495 「SDOI2011」消耗战 虚树
问题描述 LG2495 题解 虚树 \(\mathrm{Code}\) #include<bits/stdc++.h> using namespace std; #define int l ...
- 【BZOJ4556】[TJOI2016&HEOI2016] 字符串(后缀自动机+线段树合并+二分)
点此看题面 大致题意: 给你一个字符串\(s\),每次问你一个子串\(s[a..b]\)的所有子串和\(s[c..d]\)的最长公共前缀. 二分 首先我们可以发现一个简单性质,即要求最长公共前缀,则我 ...