【问题标题】:WCF Timeout Issue in iOSiOS 中的 WCF 超时问题
【发布时间】:2015-04-22 13:17:09
【问题描述】:

我正在将 C# 用于我一直在开发的 ios 应用程序。我遇到了超时问题。

我关注了以下链接 http://developer.xamarin.com/guides/cross-platform/application_fundamentals/web_services/

这是我的客户助手

public class ClientHelper
{
    // DM Service Address
    private static readonly EndpointAddress EndPoint = new EndpointAddress("https://xxxxxxx/aaaaa/bbbbb.svc/basic");

    public static DMServiceClient CreateClient ()
    {
        var binding = CreateBasicHttp();

        return    new DMServiceClient(binding, EndPoint);
    }


    private static BasicHttpBinding CreateBasicHttp()
    {
        var binding = new BasicHttpBinding()
        {
            Name = "BSHttpBinding",
            MaxReceivedMessageSize = 2147483647,
            MaxBufferSize = 2147483647  
        };

        binding.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas()
        {
            MaxArrayLength = 2147483646,
            MaxStringContentLength = 524288045

        };

        var timeout = new TimeSpan(0, 0, 2);
        binding.SendTimeout = timeout;
        binding.OpenTimeout = timeout;
        binding.ReceiveTimeout = timeout;
        binding.CloseTimeout = timeout;

        binding.Security.Mode = BasicHttpSecurityMode.Transport;
        return binding;
    }
}

进程可能需要超过 10 秒,我将超时设置为 2 秒,但没有发生任何异常。

我们在桌面应用程序中尝试并将其设置在 appconfig 文件中,它可以工作。在 iOS 应用程序中,没有 appconfig 文件,然后我会手动设置超时。

【问题讨论】:

  • 你有什么问题是超时?因为该过程需要 10 秒,而您指定 2 秒,所以它不起作用
  • 我的意思是即使我将超时设置为 2 秒,也不会发生超时异常。例如,一个进程需要 10 秒才能完成,我给了 2 秒作为超时,但它不考虑我的超时..

标签: c# ios wcf


【解决方案1】:

我找到了答案..有趣,没有关于它的信息..

   service.InnerChannel.OperationTimeout = TimeSpan.FromSeconds(30.0); 

所以它解决了我的问题.. https://stackoverflow.com/a/10108281/1022138

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-06-19
    • 2011-12-28
    • 2011-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-13
    相关资源
    最近更新 更多