首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >HTTPS调用异常“由于意外的数据包格式,握手失败。”

HTTPS调用异常“由于意外的数据包格式,握手失败。”
EN

Stack Overflow用户
提问于 2020-10-22 16:38:00
回答 1查看 317关注 0票数 1

当从windows服务进行REST api调用(使用https方案)时,我得到一个异常,它指出“握手失败是由于意外的数据包格式。”如果将域用户分配为服务登录帐户,则上述异常将会消失。

此外,在开发阶段(Visual studio 2015,C#),我没有得到任何异常。

代码语言:javascript
复制
***Code Snippet:***
 ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
 HttpClient Client = new HttpClient();
 var response = await Client.PostAsync("https://auth.brivo.com/oauth/token", httpContent, cancellationToken).ConfigureAwait(false);

***Exception Thrown:***
System.Net.Http.HttpRequestException occurred
  HResult=-2146233088
  Message=An error occurred while sending the request.
  Source=mscorlib
  StackTrace:
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult()
       at Sisco.FastPass.AccessControl.Brivo.HttpClientHelper.<PostFormDataRequest>d__5`2.MoveNext()
  InnerException: 
       HResult=-2146233079
       Message=The underlying connection was closed: An unexpected error occurred on a send.
       Source=System
       StackTrace:
            at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
            at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
       InnerException: 
            HResult=-2146232800
            Message=**The handshake failed due to an unexpected packet format.**
            Source=System
            StackTrace:
                 at System.Net.TlsStream.EndWrite(IAsyncResult asyncResult)
                 at System.Net.PooledStream.EndWrite(IAsyncResult asyncResult)
                 at System.Net.ConnectStream.WriteHeadersCallback(IAsyncResult ar)
            InnerException: 
EN

回答 1

Stack Overflow用户

发布于 2020-10-22 19:20:00

如下所示参考此链接并选中启用ssl协议部分:https://www.limilabs.com/blog/the-handshake-failed-due-to-an-unexpected-packet-format

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64478396

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档