Xamarin iOS RestSharp请求会挂起每个X请求

时间:2014-12-04 17:11:22

标签: xamarin.ios xamarin restsharp

我遇到了一些POST请求到服务器的问题(https / ssl)。

问题在于每个X请求,一个请求只是挂起并且似乎没有被发送到服务器,至少是我在使用fiddler嗅探iPhone之后的想法。

有时我会在几分钟后收到此消息:

获取响应流时出错(ReadDone1):ReceiveFailure

和innerException堆栈跟踪:

位于///Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.43/src/mono/mcs/class/System/中的System.Net.Sockets.NetworkStream.EndRead(IAsyncResult ar)[0x0003d] System.Net.Sockets / NetworkStream.cs:322位于//Library/Frameworks/Xamarin.iOS.framework/Versions/8.4.0.43/中的Mono.Security.Protocol.Tls.SslStreamBase.InternalReadCallback(IAsyncResult result)[0x0002c] SRC /单声道/ MCS /类/ Mono.Security / Mono.Security.Protocol.Tls / SslStreamBase.cs:659

有没有人遇到过这样的问题或想知道如何解决?

这是我正在使用的代码:

    ThreadPool.QueueUserWorkItem (delegate {
        if (Utilities.IsOnline ()) {
            refreshData ();
        }
    });

    private void refreshData() {
            try {
            baseRequest = new BaseRequest ();
            baseRequest.id = "userid";

            string BaseUrl = "my server url";

            client = new RestClient ();
            client.BaseUrl = BaseUrl;
            client.Timeout = 5000;

            request = new RestRequest (Method.POST);
            request.RequestFormat = DataFormat.Json;
            request.Resource = "GetClientData";
            request.AddBody (baseRequest);

            serviceResponse = new ServiceResponse ();

            client.ExecuteAsync (request, response => {
                if (response.ErrorException != null) {
                    serviceResponse.payload = string.Empty;
                    serviceResponse.statusCode = StatusCode.Error;
                } else {
                    //parse data
                }

            });

        } catch (Exception ex) {

        }
}

0 个答案:

没有答案