JeffreySu / WeiXinMPSDK

微信全平台 .NET SDK, Senparc.Weixin for C#,支持 .NET Framework 及 .NET Core、.NET 8.0。已支持微信公众号、小程序、小游戏、微信支付、企业微信/企业号、开放平台、JSSDK、微信周边等全平台。 WeChat SDK for C#.
https://weixin.senparc.com
Apache License 2.0
8.48k stars 4.36k forks source link

Received an unexpected EOF or 0 bytes from the transport stream #3082

Open rocleegithub opened 1 month ago

rocleegithub commented 1 month ago

此版块专为反馈 bug 及提交需求服务,不负责解答开发问题,请勿发表开发问题, 如果您需要这方面的帮助,请移步问答社区https://weixin.senparc.com/QA

问题描述

在运行服务器上可以ping的通 ping api.weixin.qq.com,在运行服务器的浏览器上也可以正常访问地址https://api.weixin.qq.com/sns/jscode2session ,看了有一篇文章 https://www.cnblogs.com/wu_u/p/10704542.html 原因:大概是请求时默认了一个过时了的ssl协议

System.Net.Http.HttpRequestException: The SSL connection could not be established, see inner exception. ---> System.IO.IOException: Received an unexpected EOF or 0 bytes from the transport stream. at System.Net.Security.SslStream.ReceiveBlobAsync[TIOAdapter](CancellationToken cancellationToken) at System.Net.Security.SslStream.ForceAuthenticationAsync[TIOAdapter](Boolean receiveFirst, Byte[] reAuthenticationData, CancellationToken cancellationToken) at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) --- End of inner exception stack trace --- at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.AddHttp11ConnectionAsync(QueueItem queueItem) at System.Threading.Tasks.TaskCompletionSourceWithCancellation1.WaitWithCancellationAsync(CancellationToken cancellationToken) at System.Net.Http.HttpConnectionPool.HttpConnectionWaiter1.WaitForConnectionAsync(Boolean async, CancellationToken requestCancellationToken) at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken) at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at System.Net.Http.DecompressionHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken) at Microsoft.Extensions.Http.Logging.LoggingHttpMessageHandler.g__Core|5_0(HttpRequestMessage request, Boolean useAsync, CancellationToken cancellationToken) at Microsoft.Extensions.Http.Logging.LoggingScopeHttpMessageHandler.g__Core|5_0(HttpRequestMessage request, Boolean useAsync, CancellationToken cancellationToken) at System.Net.Http.HttpClient.GetStringAsyncCore(HttpRequestMessage request, CancellationToken cancellationToken) at Senparc.CO2NET.HttpUtility.RequestUtility.HttpGetAsync(IServiceProvider serviceProvider, String url, Encoding encoding) at Senparc.CO2NET.HttpUtility.Get.GetJsonAsync[T](IServiceProvider serviceProvider, String url, Encoding encoding, Action`2 afterReturnText) at Senparc.Weixin.CommonAPIs.CommonJsonSend.SendAsync[T](String accessToken, String urlFormat, Object data, CommonJsonSendType sendType, Int32 timeOut, Boolean checkValidationResult, JsonSetting jsonSetting, String contentType) at Senparc.Weixin.WxOpen.AdvancedAPIs.Sns.SnsApi.JsCode2JsonAsync(String appId, String secret, String jsCode, String grantType, Int32 timeOut)

重现问题步骤(如果可以)
  1. ...
  2. ...
微信官方文档 URL
微信官方文档快照(直接复制关键内容到下方)
发现问题的模块
模块对应的 .net 版本
开发环境
缓存环境
系统环境
联系方式

Email:304594656@qq.com

(也可将问题地址及联系方式发送到 zsu@senparc.com)

发布问题后,请保持对 issue 的关注,有时会有需要进一步沟通的信息,很长时间内没有得到答复的 issue 将被关闭。

JeffreySu commented 1 month ago

@rocleegithub 目前 SDK 内部没有对 SSL 协议做任何限制,请您观察一下部署的服务器或者开发环境的网关是否进行了特殊的限制?