我正在使用渠道工厂创建WCF代理,如下所示 -
BasicHttpBinding binding = new BasicHttpBinding();
binding.SendTimeout = new TimeSpan(0, 20, 0);
binding.ReceiveTimeout = new TimeSpan(0, 20, 0);
binding.OpenTimeout = new TimeSpan(0, 20, 0);
binding.CloseTimeout = new TimeSpan(0, 20, 0);
binding.BypassProxyOnLocal = bypassProxyOnLocal;
binding.HostNameComparisonMode = (HostNameComparisonMode)Enum.Parse(typeof(HostNameComparisonMode), hostNameComparisonMode, true);
binding.MaxBufferPoolSize = maxBufferPoolSize;
binding.MaxReceivedMessageSize = maxReceivedMessageSize;
binding.MessageEncoding = (WSMessageEncoding)Enum.Parse(typeof(WSMessageEncoding), messageEncoding, true);
binding.TextEncoding = System.Text.Encoding.UTF8;
binding.UseDefaultWebProxy = useDefaultWebProxy;
binding.AllowCookies = allowCookies;
binding.Security.Transport.Realm = securityTransportRealm;
binding.Security.Message.AlgorithmSuite = SecurityAlgorithmSuite.Default;
EndpointAddress endpointAddress = new EndpointAddress(endPoint);
ChannelFactory<T> channelFactory = new ChannelFactory<T>(binding, endpointAddress);
return channelFactory.CreateChannel();
这是生成WCF代理的通用方法。我在代码中设置了超时= 20,但仍然是抛出错误 -
Error. \nThe request channel timed out while waiting for a reply after 00:00:59.9843997. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.\n
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
请建议,我该如何解决这个问题?