如何增加请求超时时间? [英] How to increase the request timeout?

查看:175
本文介绍了如何增加请求超时时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何增加Get或GetTaskAsync的超时时间? (使用Facebook C#SDK 6)

How do I increase the TimeOut for Get or GetTaskAsync? (Using Facebook C# SDK 6)

好像他们有15秒的超时时间.

Seems like they have a timeout of 15 seconds.

推荐答案

使用FacebookClient.HttpWebRequestFactory.由于它是从智能感知中隐藏的,因此您可能无法在VS中看到它,具体取决于您的设置.

Use FacebookClient.HttpWebRequestFactory. Since it is hidden from intellisense you might not see it in VS depending on your settings.

    /// <summary>
    /// Http web request factory.
    /// </summary>
    [EditorBrowsable(EditorBrowsableState.Never)]
    public virtual Func<Uri, HttpWebRequestWrapper> HttpWebRequestFactory
    {
        get; set;
    }

您可能想做这样的事情.

You might want to do something like this.

FacebookClient.HttpWebRequestFactory = url => {
  var request = new HttpWebRequestWrapper((HttpWebRequest)WebRequest.Create(url));
  request.Timeout = .....;
  return request;
};

这至少需要v6.

对于v5,您需要覆盖一个受保护的方法.

for v5, you need to override a protected method.

    /// <summary>
    /// Creates the http web request.
    /// </summary>
    /// <param name="url">The url of the http web request.</param>
    /// <returns>The http helper.</returns>
    [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
    protected virtual HttpWebRequestWrapper CreateHttpWebRequest(Uri url);

这篇关于如何增加请求超时时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆