linux - 通过 nghttp2 使用支持 HTTP\2 的 cURL 连接到 Apple 的 APNS

标签 linux curl docker apple-push-notifications nghttp2

我尝试按照 this tutorial 编译支持 HTTP/2 的 cURL .我正在使用 Docker我的应用程序基于 official PHP Docker image ,它使用 Debian,尽管我在 Vagrant 中运行的 Ubuntu 机器中产生了同样的问题。虚拟机。

一开始似乎没有问题。事实上,运行 curl --version 显示了我所期望的一切:

curl 7.47.1 (x86_64-pc-linux-gnu) libcurl/7.47.1 OpenSSL/1.0.1k zlib/1.2.8 libidn/1.29 libssh2/1.4.3 nghttp2/1.7.1 librtmp/2.3
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp 
Features: IDN IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP HTTP2 UnixSockets 

另外,我可以连接到 https://nghttp2.org就好了:

curl --http2 -I https://nghttp2.org
HTTP/2.0 200
date:Mon, 15 Feb 2016 18:02:34 GMT
content-type:text/html
content-length:6680
last-modified:Thu, 11 Feb 2016 14:29:49 GMT
etag:"56bc9add-1a18"
link:</stylesheets/screen.css>; rel=preload; as=stylesheet
accept-ranges:bytes
x-backend-header-rtt:0.000581
server:nghttpx nghttp2/1.8.0-DEV
via:1.1 nghttpx
strict-transport-security:max-age=31536000
x-frame-options:SAMEORIGIN
x-xss-protection:1; mode=block
x-content-type-options:nosniff

当尝试连接到 Apple 最近重新启动的 APNS Provider API 时,问题就开始了。现在在 HTTP/2 上运行。

我已经通过 Homebrew 在我的 Mac 上安装了 curl(使用 --with-nghttp2),我可以获得以下(预期的)响应:

curl -d 'Hello' --http2 https://api.push.apple.com/3/device/test
{"reason":"Forbidden"}

但是,如果我尝试从我的 Docker 镜像中运行相同的命令,我会得到:

curl -d 'Hello' --http2 https://api.push.apple.com/3/device/test
?@@?HTTP/2 client preface string missing or corrupt. Hex dump for received bytes: 504f5354202f332f6465766963652f746573742048545450

我不确定为什么这个问题似乎是 Apple 服务特有的,以及需要采取什么措施来补救这种情况。

如有任何帮助,将不胜感激!

最佳答案

对于将来看到此问题的任何人,我最终解决了这个问题,答案在 Server Fault 上.

关于linux - 通过 nghttp2 使用支持 HTTP\2 的 cURL 连接到 Apple 的 APNS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35416247/

相关文章:

linux - "Failed to connect to github.com port 443: Connection timed out"推送到远程仓库时

c++ - CURL 不遵循 301 重定向,我需要做什么?

docker - 工作从哪里获取环境变量?

docker - COPY 不会将我的文件添加到 Docker 容器

linux - 本地和 Hadoop 文件之间的差异

linux - 如何使用位于 azure webapp 中的 .sh 文件将多个文件从本地存储上传到 azure blob 存储

json - 如何将单引号转义成双引号转成单引号

Docker 看不到项目文件的变化

c++ - linux/unix 下是否有相当于 WinAPI 的 MAX_PATH 的?

php - cURL + 通过浏览器下载文件