Q:

Connection closed by foreign host while using telnet

I am developing push notification first time and came across this telnet command:
telnet gateway.push.apple.com 2195
I get following response by using this command
Trying 17.172.233.151...
Connected to gateway.push-apple.com.akadns.net.
Escape character is '^]'

but after approx 30 sec,It shows like "Connection closed by foreign host" so I am confused whether my server is connected to Apple Push Notification Server or not!
Any help would be greatly appreciated,Thanks!

A:

See this tutorial. Once you've got the necessary certificates, use this to test if you can successfully connect to the apns:
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert PushChatCert.pem -key PushChatKey.pem 
NOTE: if you've encountered an error like error:num=20:unable to get local issuer certificate, just download entrust_2048_ca.cer, and together with the other certificates, you can check it like this:
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert PushChatCert.pem -key PushChatKey.pem -CAfile entrust_2048_ca.cer

