发送时发生意外错误。 TLS1.1连接错误

时间:2018-07-03 17:21:50

标签: vb.net tls1.2

我们在已编译并正在进行Web服务调用的服务器上有一些旧的VB代码。提供程序最近从TLS1.1更新到TLS1.2,此时代码停止工作,我们开始收到错误消息

  

基本连接已关闭:发送中发生意外错误

我对VB不太熟悉。我们可以在 Windows Server 上进行任何更改,以便编译后的代码通过TLS1.2建立连接吗?

花了一些时间,但是我添加了堆栈跟踪。为了隐私起见,我对其进行了一些编辑:

这是错误消息:

  

基础连接已关闭:发送中发生意外错误。
  跟踪:
  在System.Web.Services.Protocols.WebClientProtocol.GetWebResponse(WebRequest请求)
  在System.Web.Services.Protocols.HttpWebClientProtocol.GetWebResponse(WebRequest请求)
  在System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(字符串methodName,Object []参数)
  在(......)。BeginSession(String Profile)在C:\ Users ... \ Desktop ................ ............. vb:第146行
  在C:\ Users(..........................)中的(.......)RetrieveData(Int32 queueNumber) ..............)。vb:475行
  在C:\ Users(............ ...........)vb:第121行

这是建立Web服务连接的代码的一部分(上面堆栈中的第146行):

<System.Web.Services.Protocols.SoapDocumentMethodAttribute("......BeginSession", RequestNamespace:="........com", ResponseNamespace:=".............com", Use:=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle:=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)> _
Public Function BeginSession(ByVal Profile As String) As String
  Dim results() As Object = Me.Invoke("BeginSession", New Object() {Profile})
  Return CType(results(0), String)
End Function

2 个答案:

答案 0 :(得分:0)

在请求之前添加此内容:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12
ServicePointManager.Expect100Continue = True

我认为这样就可以了。

当我遇到错误时,为我工作,尽管有点不同。

答案 1 :(得分:0)

我的问题已解决。我采取的步骤是通过在最新版本的Visual Studio(2017)中打开项目来升级项目。我在升级时遇到了一些错误,这主要与解决方案文件为只读有关。然后,我将项目的目标框架更改为4.6.1。 完成这些更改并重建解决方案后,该应用程序似乎可以正常工作。