简体   繁体   English

在Windows Server 2012 R2上发送http / 2请求

[英]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.

相关问题 Windows Server 2012 r2 中的波斯文化 - Persian culture in Windows Server 2012 r2 405 - 不允许用于访问此页面的 HTTP 动词。 [IIS 8.5] [Windows Server 2012 R2] - 405 - HTTP verb used to access this page is not allowed. [IIS 8.5] [Windows Server 2012 R2] 如何为Windows Server 2012 R2的出站请求启用TLS 1.2? - How to enable TLS 1.2 for outbound request from windows server 2012 R2? Windows Server 2012 R2上Windows Service Platform上的WCFNotSupportedException - WCF on Windows Service PlatformNotSupportedException On Windows Server 2012 R2 在 Windows Server 2012 R2 上构建的应用程序在 Windows Server 2008 R2 上失败 - Application built on Windows Server 2012 R2 fails on windows server 2008 R2 Windows Server 2012 R2上的意外崩溃WCF服务 - Unexpected crash WCF Service on Windows Server 2012 R2 Active Directory中的用户身份验证-Windows Server 2012 R2 - User Authentication in Active Directory - Windows Server 2012 R2 无法在 Windows 2012 R2 服务器上加载 DLL“tensorflow” - Unable to load DLL 'tensorflow' on Windows 2012 R2 Server 将 .net core 项目部署到 Windows Server 2012 r2 - Deploy .net core project to Windows Server 2012 r2 在Windows Server 2012 r2上部署时出现BadImageFormatException - BadImageFormatException when deploying on windows server 2012 r2
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM