Apple推送代理和stream_context

Pie*_*rre 6 php http-proxy apple-push-notifications

我必须向iOS设备发送推送通知.我的连接必须通过代理启用.我尝试了一切但没有成功.我有一个错误110连接超时.如果我只是尝试连接Apple推送地址,它正在使用cURL.我不知道问题出在哪里.代理配置?PHP stream_context错误的实现?

这是我的代码:

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'certificate.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', 'my_passphrase');
stream_context_set_option($ctx, 'ssl', 'verify_peer', false);
stream_context_set_option($ctx, 'http', 'proxy', 'tcp://my-proxy.net:8080');
stream_context_set_option($ctx, 'http', 'request_fulluri', true);

$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
var_dump($fp);
var_dump($err);
var_dump($errstr);
exit;
Run Code Online (Sandbox Code Playgroud)

你有好主意吗 ?

编辑:

它可以直接链接到Squid吗?我刚刚发现代理正在运行Squid.我也尝试使用fopen()函数而不是stream_socket_client()它似乎不允许ssl协议.

这是我的var_dump输出:bool(false)int(110)string(20)"连接超时"

我也有这个警告:警告:stream_socket_client():无法连接到第22行/share/www/website/test.php中的ssl://gateway.sandbox.push.apple.com:2195(连接超时)

Dan*_*ack 1

这可能只是您的代理不允许打开端口 2195。

iPhone 推送通知无法连接到 SSL 服务器

我猜你要么:

  • 需要与运行代理的人员联系以查看端口 2195 是否打开。

或者

  • 设置一个监听端口 2195 的测试服务器,然后尝试通过代理对其进行测试连接。这应该允许您测试是否是代理阻止了连接请求。

或者

  • 测试 Curl 是否可以使用代理打开连接。

这是通过设置选项来完成的:

// sets the proxy to go through
curl_setopt($ch, CURLOPT_PROXY, $proxy);
// sets to use a tunnel proxy which most http proxies are
curl_setopt($ch, CURLOPT_HTTPTUNNELPROXY, $proxy);
Run Code Online (Sandbox Code Playgroud)

完整的测试代码在这里