我在本地机器上测试了推送通知,它工作正常。然后我用相同的证书(“.pem”文件)将我的文件上传到真实服务器,并确保端口2195和2196处于打开状态。ios推送通知不能在服务器上工作
我测试:
telnet gateway.sandbox.push.apple.com 2195
它的工作...
[email protected] ~ # telnet gateway.sandbox.push.apple.com 2195
Trying 17.149.34.54...
Connected to gateway.sandbox.push.apple.com.
Escape character is '^]'.
但是,当我从我的PHP脚本测试,它返回:
警告:stream_socket_client() [function.stream-socket-client]: 无法连接到ssl://gateway.sandbox.push.apple.com:2195 (Co nnection超时)
警告:stream_socket_client()[function.stream插座-客户]: 无法连接到SSL://feedback.sandbox.push.apple.com:2196
不限建议?
这是PHP代码:
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert',
"path/to/certificate");
$fp = stream_socket_client("ssl://gateway.push.apple.com:2195",
$error, $errorString, 100,
(STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT), $ctx);
请显示您的整个PHP代码... – powtac
$ ctx = stream_context_create(); \t \t stream_context_set_option($ ctx,'ssl','local_cert',“path/to/certificate”); $ fp = stream_socket_client(“path/to/certificate”,$ error,$ errorString,100,(STREAM_CLIENT_CONNECT | STREAM_CLIENT_PERSISTENT),$ ctx); – yasserislam
最好把这个添加到你的问题中,只需编辑它。 –