[英]send http/2 request on windows server 2012 R2
I want to consume the APNs push service in my application so i use this code: 我想在应用程序中使用APNs推送服务,所以我使用以下代码:
var responseString = string.Empty;
using (var request = new HttpClient(new Http2CustomHandler()))
{
var content = new StringContent(body);
request.DefaultRequestHeaders.Add("authorization", $"bearer {authorization}");
request.DefaultRequestHeaders.Add("apns-topic", topicName);
if (!string.IsNullOrWhiteSpace(iD)) request.DefaultRequestHeaders.Add("apns-id", iD);
if (!string.IsNullOrWhiteSpace(expiration)) request.DefaultRequestHeaders.Add("apns-expiration", expiration);
if (!string.IsNullOrWhiteSpace(priority)) request.DefaultRequestHeaders.Add("apns-priority", priority);
if (!string.IsNullOrWhiteSpace(collapseID)) request.DefaultRequestHeaders.Add("apns-collapse-id", collapseID);
var result = request.PostAsync(url, content).GetAwaiter().GetResult();
responseString = result.Content.ReadAsStringAsync().GetAwaiter().GetResult();
}
its working just fine on my machine(windows 10). 它在我的机器上正常工作(Windows 10)。 but when i deploy the application on my server(windows server 2012 R2) it throws this exception: 但是,当我在服务器(Windows Server 2012 R2)上部署应用程序时,会引发此异常:
System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.Http.WinHttpException: A security error occurred
is there any way to solve this problem? 有什么办法解决这个问题?
You most probably have already discovered that it could be because HTTP/2 is only supported in Windows Server 2016 (IIS10) and Windows 10. 您很可能已经发现这可能是因为Windows Server 2016(IIS10)和Windows 10仅支持HTTP / 2。
The version of IIS on Windows Server 2012 does not support HTTP/2. Windows Server 2012上的IIS版本不支持HTTP / 2。
See https://docs.microsoft.com/en-us/iis/get-started/whats-new-in-iis-10/http2-on-iis 请参阅https://docs.microsoft.com/zh-cn/iis/get-started/whats-new-in-iis-10/http2-on-iis
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.