gpt4 book ai didi

ssl - "The underlying connection was closed: An unexpected error occurred on a send."带SSL证书

转载 作者:太空宇宙 更新时间:2023-11-03 12:36:39 26 4
gpt4 key购买 nike

问题

我得到这个异常

The underlying connection was closed: An unexpected error occurred on a send.

在我的日志中,它会随机破坏我们的 OEM 与我们的电子邮件营销系统的集成。 (1-4 小时不等)

我的网站托管在带有 IIS 7.5.7600 的 Windows Server 2008 R2 上。

该网站有大量的 OEM 组件和全面的仪表板。除了我们在仪表板中用作 iframe 解决方案的电子邮件营销组件之外,一切都适用于网站的所有其他元素。

它的工作方式是,我发送一个 HttpWebRequest 反对所有凭据,我得到一个 url,我将其放入 iframe 并且它有效。

但它只工作一段时间(1-4小时),然后从调用到

webRequest.GetResponse();

我得到异常

The underlying connection was closed: An unexpected error occurred on a send.

即使系统尝试从 httpWebRequest 获取 URL,它也会失败并出现相同的异常。

让它再次工作的唯一方法是:

  • 回收应用程序池
  • 在 web.config 中编辑任何内容。

我真的用尽了我能想到的所有选择。

尝试过的选项

明确添加,

  • keep-alive = false

  • keep-alive = true

  • 增加超时时间:

    <httpRuntime maxRequestLength="2097151" executionTimeout="9999999" enable="true" requestValidationMode="2.0" />

我已将此页面上传到非 SSL 网站,以检查我们的生产服务器上的 SSL 证书是否正在建立连接以某种方式断开连接。

非常感谢任何解决问题的方向。

代码


Public Function CreateHttpRequestJson(ByVal url) As String
Try
Dim result As String = String.Empty
Dim httpWebRequest = DirectCast(WebRequest.Create("https://api.xxxxxxxxxxx.com/api/v3/externalsession.json"), HttpWebRequest)
httpWebRequest.ContentType = "text/json"
httpWebRequest.Method = "PUT"
httpWebRequest.ContentType = "application/x-www-form-urlencoded"
httpWebRequest.KeepAlive = False
'ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3

'TODO change the integratorID to the serviceproviders account Id, useremail
Using streamWriter = New StreamWriter(httpWebRequest.GetRequestStream())
Dim json As String = New JavaScriptSerializer().Serialize(New With { _
Key .Email = useremail, _
Key .Chrome = "None", _
Key .Url = url, _
Key .IntegratorID = userIntegratorID, _
Key .ClientID = clientIdGlobal _
})

'TODO move it to the web.config, Following API Key is holonis accounts API Key
SetBasicAuthHeader(httpWebRequest, holonisApiKey, "")
streamWriter.Write(json)
streamWriter.Flush()
streamWriter.Close()

Dim httpResponse = DirectCast(httpWebRequest.GetResponse(), HttpWebResponse)
Using streamReader = New StreamReader(httpResponse.GetResponseStream())
result = streamReader.ReadToEnd()
result = result.Split(New [Char]() {":"})(2)
result = "https:" & result.Substring(0, result.Length - 2)
End Using
End Using
Me.midFrame.Attributes("src") = result
Catch ex As Exception
objLog.WriteLog("Error:" & ex.Message)
If (ex.Message.ToString().Contains("Invalid Email")) Then
'TODO Show message on UI
ElseIf (ex.Message.ToString().Contains("Email Taken")) Then
'TODO Show message on UI
ElseIf (ex.Message.ToString().Contains("Invalid Access Level")) Then
'TODO Show message on UI
ElseIf (ex.Message.ToString().Contains("Unsafe Password")) Then
'TODO Show message on UI
ElseIf (ex.Message.ToString().Contains("Invalid Password")) Then
'TODO Show message on UI
ElseIf (ex.Message.ToString().Contains("Empty Person Name")) Then
'TODO Show message on UI
End If
End Try
End Function


Public Sub SetBasicAuthHeader(ByVal request As WebRequest, ByVal userName As [String], ByVal userPassword As [String])
Dim authInfo As String = Convert.ToString(userName) & ":" & Convert.ToString(userPassword)
authInfo = Convert.ToBase64String(Encoding.[Default].GetBytes(authInfo))
request.Headers("Authorization") = "Basic " & authInfo
End Sub

最佳答案

对我来说是 tls12:

ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;

关于ssl - "The underlying connection was closed: An unexpected error occurred on a send."带SSL证书,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22627977/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com