I have to confirm that my PHP code for sending push notification is working with a proxy. I installed Charles and I’m able to watch all my web traffic through a proxy (127.0.0.1:8888).
Now I would like to see if my script is correctly working for push notifications.
I have :
stream_context_set_option($ctx, 'http', 'proxy', 'tcp://127.0.0.1:8888');
$fp = stream_socket_client('ssl://gateway.sandbox.push.apple.com:2195', $err,$errstr, 60, STREAM_CLIENT_CONNECT, $ctx);
I’m getting my push notification but I can’t see what is happening in Charles. So my script is not using proxy …
Do you know why ?
This is because you passed a context with
httpoptions tostream_socket_client()– and more to the point you used anssl://wrapper instead ofhttp://orhttps://.The
stream_socket_*()functions do not know that you are implementing HTTP so they do not use thehttpcontext options – in order for this to work you would need to do e.g.This is probably a better idea anyway, because it is unlikely you would need the granular control that implementing HTTP manually would give you for the Apple APIs.