问题
Monotouch/WCF: why cannot override the wcf binding default timeout setting:
public class MyServiceClient : ClientBase<IMyContract>,IMyContract
{ ... }
public void test() {
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
basicHttpBinding.Name = "basicHttpBinding";
basicHttpBinding.MaxBufferSize = int.MaxValue;
basicHttpBinding.MaxReceivedMessageSize = int.MaxValue;
basicHttpBinding.ReceiveTimeout = TimeSpan.FromSeconds(10.0);
basicHttpBinding.SendTimeout = TimeSpan.FromSeconds(10.0);
basicHttpBinding.CloseTimeout = TimeSpan.FromSeconds(5.0);
basicHttpBinding.OpenTimeout = TimeSpan.FromSeconds(5.0);
MyServiceClient client = New MyServiceClient(basicHttpBinding, new EndPointAddress(...));
client.Test();
}
// Althought I set the OpenTimeout to 5 seconds, but when I close the server service(or close the iphone's wifi & network), it still try to connect to the service in the background until the default 1 miniute timeout, it's strange! Why? thanks.
btw, the exception in monotouch/iPhone throw after 1 minutes,the type is TimeoutException(message:The operation has timed-out.) not the FaultException or CommunicationException). If the above code invoke in windows .net client, it should be throw the CommunicationException.
回答1:
xamarin team reply: serviceClient.innerchannel.operationtimeout = ... thanks.
来源:https://stackoverflow.com/questions/10062830/monotouch-wcf-why-cannot-override-the-wcf-binding-timeout-setting