我有一个作为 .NET 控制台应用程序运行的 XML-RPC 服务器(使用 XML-RPC.net)。我正在尝试通过我的 ASP.NET Core (2.1.1) Web 应用程序连接到它,但客户端一直超时。邮递员也会立即返回响应,没有问题。
我是这样称呼它的:
HttpClient client = _clientFactory.CreateClient();
client.Timeout = TimeSpan.FromSeconds(10);
var httpRequest = new HttpRequestMessage(HttpMethod.Post, instance.ServiceUrl);
var stringContent = new ByteArrayContent(Encoding.UTF8.GetBytes(request.ToString()));
httpRequest.Content = stringContent;
httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("text/xml");
var httpResponse = await client.SendAsync(httpRequest);
var response = await httpResponse.Content.ReadAsByteArrayAsync();
当控制台应用程序返回响应时,我可以看到请求已成功发出。Fiddler 显示有 200 响应但await client.SendAsync(httpRequest);
超时!
请求通常在 10 毫秒内完成,因此超时值仅用于调试,如果我将其忽略,则需要 60 秒。响应返回 XML。
我试过重写这个来使用StringContent
和使用PostAsync
,同样的问题。我也尝试使用重写它,WebClient
但它返回The remote server returned an error: (100) Continue.
不确定这是否相关。
一直卡在这个问题上,有人知道会发生什么吗?