I'm working on APNS (Apple Push Notification Service). I'm doing it as tutorials said:
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');
stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase);
$fp = stream_socket_client(
'ssl://gateway.sandbox.push.apple.com:2195', $err,
$errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx);
But on my server, I have to connect to the internet via a HTTP proxy, so I always got timeout error with those code. How can I set http proxy for strem_socket_client with ssl protocol?
Best way is to set proxy
options with stream_context_create
:
$ctx = stream_context_create(array(
'http' => array(
'proxy' => 'tcp://127.0.0.1:8888',
)
)
);
See http://php.net/manual/en/context.http.php for full http options.
Maybe you will have to set request_fulluri
to true.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With