我有一个Xamarin iOS应用程序在连接到我们的许多内部https服务器时达到超时(10分钟)。应用程序用于连接的代码是:
HttpRequestMessage message = new HttpRequestMessage(HttpMethod.Post, uri);
[Headers and content are added to message here - I can't easily post up
the details for security reasons, but if anyone thinks that that might
be causing the problem, I'll work something out.]
System.Net.Http.HttpClientHandler handler = new System.Net.Http.HttpClientHandler();
handler.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
System.Net.Http.HttpClient client = new System.Net.Http.HttpClient(handler);
client.MaxResponseContentBufferSize = 900000000;
client.Timeout = TimeSpan.FromSeconds(600);
HttpResponseMessage response = await client.SendAsync(message, HttpCompletionOption.ResponseHeadersRead);
我在超时时收到的消息是:A task was cancelled
。
我已经对此进行了相当多的研究,这些是我的发现:
我已将App Transport Security添加到应用的Info.plist中,从而关闭了App Transport:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
我从与iOS模拟器相同的机器上运行了ATS诊断工具(/usr/bin/nscurl --ats-diagnostics [URL]
),一切都过去了。
任何想法还有什么可能是问题以及我还能尝试什么?!我突然强调了上面关于Fiddler的观点,因为我怀疑它可能是一个很大的线索 - 当服务器在解密模式下通过Fiddler连接时,服务器与应用程序有何不同?