2017-11-08 6 views
0

HttpClient에 대한 TCP 연결 시간 제한을 구성해야합니다. 현재 전체 요청에 사용 된 일반적인 시간 제한을 사용하고 있지만 응용 프로그램의 POST를 올바르게 제어하는 ​​것으로는 충분하지 않습니다.HttpClient의 시간 초과 TCP 연결

 Using client As New HttpClient() 
       Dim bArrayCredentials As Byte() = Encoding.UTF8.GetBytes(ConfigurationManager.AppSettings("LDAPUser") & ":" & ConfigurationManager.AppSettings("LDAPPass")) 
       client.DefaultRequestHeaders.Authorization = New AuthenticationHeaderValue("Basic", Convert.ToBase64String(bArrayCredentials)) 
       client.Timeout = TimeSpan.FromSeconds(CDbl(ConfigurationManager.AppSettings("TimeoutResponseLoginTVS")))     

       client.BaseAddress = New Uri(ConfigurationManager.AppSettings("URLLogin")) 
       Dim peticion = JsonConvert.SerializeObject(objPeticion) 
       Dim content As New StringContent(peticion, System.Text.Encoding.UTF8, "application/json") 
       Dim response As HttpResponseMessage = client.PostAsync(page, content).Result 
       If IsResponseValid(response.StatusCode) Then 
        Dim result As String = response.Content.ReadAsStringAsync().Result 
        Return result 
       End If 

       Return Nothing 
      End Using 

¿ HttpClient에 대한 TCP 연결 시간 제한을 구성 할 수있는 방법이 있습니까?

마지막 질문에 답변 할 수없는 경우 HttpWebRequest에 대한 TCP 연결 시간 제한을 구성 할 수 있습니까?

+0

이 그것을하고 올바른 방법 :
예는 5 분 시간 제한을 설정. 그 실제 문제는 무엇입니까? – Chillzy

+0

이 버전에서는 자체적으로 연결 시간 초과를 제어 할 수 없으며 전체 청원 시간 제한 만 제어 할 수 있습니다. 별도로 구성하려고합니다. – miguelg93

+0

무엇을 의미합니까? – Chillzy

답변

0

기본적으로 httpclient의 시간 제한은 100 초로 설정되어야합니다.

Dim Timeout As TimeSpan = TimeSpan.FromMinutes(5) 
client.Timeout = Timeout