SoapHttpClientProtocol:调用WSACancelBlockingCall中断了阻塞操作

时间:2018-03-01 14:16:14

标签: c# socketexception

我使用SoapHttpClientProtocol将请求发送到Web服务。有时我得到SocketException:'阻塞操作被调用WSACancelBlockingCall'中断。 我看到以下调用堆栈:

System.IO.IOException: Unable to read data from the transport connection: A 
blocking operation was interrupted by a call to WSACancelBlockingCall. ---> 
System.Net.Sockets.SocketException: A blocking operation was interrupted by a call to WSACancelBlockingCall
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)

...

System.Net.WebException: The operation has timed out
at System.Net.HttpWebRequest.GetRequestStream(TransportContext& context)
at System.Net.HttpWebRequest.GetRequestStream()
at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)

我只是打电话给SoapHttpClientProtocol.Invoke而没有别的。 如果是带有代理和防火墙的机器,我会遇到这个问题。我想这可能是原因,但我无法理解如何以及如何解决它。

1 个答案:

答案 0 :(得分:0)

尝试使用

增加超时

System.Web.Services.Protocols.SoapHttpClientProtocol.Timeout

在你打电话之前。

如果这不起作用,那么您可能需要查看防火墙设置,假设它永远无法通过防火墙。