I followed this youtube tutorial on how to send push notifications: https://www.youtube.com/watch?v=_3YlqWWnI6s
When I run the php file on my webserver however it times out giving me this error. I have looked at the web and nothing I could find seems to be the problem, can someone suggest where I have gone wrong..
[14-Dec-2015 06:13:10 America/New_York] PHP Warning: stream_socket_client(): unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection timed out) in /home2/sptechno/public_html/Wink/sendPush.php on line 18
when you run .php file for Apple push notification.
That time you need to check the TCP/UDP Port number is open on your server other wise notification not pass to apple server.
General Provider Requirements
As a provider you communicate with Apple Push Notification service
over a binary interface. This interface is a high-speed, high-capacity
interface for providers; it uses a streaming TCP socket design in
conjunction with binary content. The binary interface is asynchronous.
The binary interface of the production environment is available
through gateway.push.apple.com, port 2195; the binary interface of the
development environment is available through
gateway.sandbox.push.apple.com, port 2195.
Apple official document for that.
EDITED
Check for your server is connected to APNS.
HOSTGATOR:~ Home$ telnet gateway.sandbox.push.apple.com 2195
Trying 17.149.34.143...
Connected to gateway.sandbox.push-apple.com.akadns.net.
Escape character is '^]'.
Related
I came to an understanding that FTP connect or any FTP related methods will not work in Bluemix. Is there any twerk or any method that i should include or prefer to make my php application work in Bluemix.
If that is not possible, is there any other service providers like Bluemix that i can use to host my php application ?
for outcoming communication on port: 21 you shouldn't have any issues in Bluemix. It is opened. Instead, all incoming communication on ftp port are blocked. (you can only use http and https port)
Bluemix is a platform as a service (PaaS) based on the Cloud Foundry. It makes no sense to enable the port 21 for incoming traffic. And it should be the same for other platform as a service based on CF.
I have an iOS app that's beta released since yesterday, but since today the push messages that were send via the Apple production server didn't seem to arrive to the users' phones. I recreated the certificate in the Apple Developer Center, tested it on my local server and verified that the new certificate was working.
Then I deployed the new certificate to my live server, but I keep getting this error message:
stream_socket_client(): unable to connect to ssl://gateway.push.apple.com:2195 (Connection refused)
I've made sure that I really uploaded the new certificate, but even resetting my live server wasn't helping.
I uploaded my project to another live server (a Google Cloud Instance) to verify if the certificate was only working on my local server or if it was just my live server that isn't working properly and the Google live server did deliver the push messages to the devices without an error message.
So it seems my default live server is the only server from where production push messages are not working. The pushes that are sent with the development certificate are delivered from every server successfully by the way.
Why could it be that I can't send push messages from that one specific server? Does anybody have any idea?
You have to check if Push Notification can be send from your server or not. That means the port 2195 should be opened in your server to do the same. Due to technical/ security reasons most of the hosting company blocking the port, you can ask them to open it if they can.
You can confirm whether this is opened or not in your server definitively by using telnet and specifying which port to connect to. From the command line run:
MyServer:~ Home$ telnet gateway.sandbox.push.apple.com 2195
Trying 17.149.34.143...
Connected to gateway.sandbox.push-apple.com.akadns.net.
Escape character is '^]'.
If there is an error connecting then it will just hang and not return - the above shows a working example where I can connect.
You'll need an SSH login to your hosting service to test it this way, and unfortunately you are unlikely to be able to test it on shared hosting without buying an account for VPS hosting- so you probably have to rely on asking their customer services.
Note: However shared hosting from Hostgator, dreamhost is working, you can chat with their support team before purchasing.
I am an iphone developer.I am trying for push notification . I created certificates,provisional profiles and php script.And i try to run in terminal,then it work nice.But when i upload it in my server,notification come sometimes mostly it show following error
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection refused)
Failed to connect: 111 Connection refused
I placed the ck.pem file in the same directory of php file. Does it require to add the path?
it seems you lose the connection during the push notification, and yes you should add the path
make sure you double check that the port your using is correct and open.
Also note that Push notification is also not always guaranteed. You can refer 'More about Push notification' section in https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/WhatAreRemoteNotif.html
Quality of Service
Apple Push Notification Service includes a default Quality of Service (QoS) component that
performs a store-and-forward function. If APNs attempts to deliver a notification but the device
is offline, the QoS stores the notification. It retains only one notification per application
on a device: the last notification received from a provider for that application.
When the offline device later reconnects, the QoS forwards the stored notification to the device.
The QoS retains a notification for a limited period before deleting it.
If a device is offline (either turned off or just unreachable) then it will receive at most a single push notification you attempt to send to your application during that time.
The question has already been asked on this forum but my concern in different. I have shared server space on Crazy domains and Blue Host. I have tried sending push notification with both of them. When i try it on Crazy Domain I get the following error:
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2196 (Connection timed out) in /home4/karmamob/public_html/pushNotification/api.php on line 20
Failed to connect: 110 Connection timed out
When i run the same on Crazy Domain , I get the following error.
Warning: stream_socket_client() [function.stream-socket-client]: unable to connect to ssl://gateway.sandbox.push.apple.com:2196 (Connection timed out) in /home4/karmamob/public_html/pushNotification/api.php on line 20
Failed to connect: 110 Connection timed out
There should be no issues with the certificate because it runs fine on my local mac PC.
What i want to ask is, Can I solve this problem if I buy a Dedicated IP from BLUE HOST?
No you don't. Shared hosting plans tend to have controlled environments that you, as a shared user, can't really change, such as open or blocked ports. Is there any way you can check if connections through port 2196 are being successfully established (not necessarily to Apple)? Some low-cost, shared plans are known for blocking some juice in favour of stability and security. Also check if your push certs are properly uploaded. Cheers.
Yes, as NewObjective clarified, 2195 & 2196 ports have to be open. To open these ports you might ask Bluehost technical support team (ticket/chat), but you have to have dedicated IP address before that.
But there is another issue. If you try to send push notification message right after dedicated IP address is set and both ports are open you might receive the same "Connection timed out" error. You can test that problem by logging in to your server via SSH and running "telnet gateway.sandbox.push.apple.com 2195" command. If you receive "Connection timed out" error - you can try to contact Bluehost support team, but they can't solve this problem.
If you try to telnet any other server with 2195 opened port you will also receive that error. I had about 10 chats with Bluehost support team, opened 10 or so tickets, but they really couldn't help me. But two weeks later everything began to work. I think it was because turning dedicated IP on takes some time, but I'm not sure. Anyway, it very interesting that Bluehost support team always answers that the problem is on the Apple side, even if you tell them that any other server with 2195 opened port isn't available too)
I am using NetworkRedux shared hosting and following the APNs setup instructions at http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12 then I get this:
Warning: stream_socket_client() [function.stream-socket-client]: unable to
connect to ssl://gateway.sandbox.push.apple.com:2195 (Connection timed out) in
FILEPATH on line 21
Failed to connect: 110 Connection timed out
It looks like they are blocking this, lame. Is there a may I can use my same script including my private key and everything to connect to a proxy that will connect to Apple? I am not interested in services that "do push for you" or web APIs or anything. I want a temporary fix that I can build off of and then remove when I migrate this to a real host, that doesn't block those ports.
Actually it is possible, but direct is the best way if possible in your environment. If you have to use an HTTP Proxy, then all you need to do is connect to the proxy, then create an HTTP Tunnel through the proxy to Apple's servers - don't initiate the TLS with Apple until after the proxy connection is create. Here is some good documentation on creating such a HTTP Tunnel with PHP: http://kakku.wordpress.com/2007/11/25/proxy-hacks-final-httptunnel-tcpip-connections-over-plain-old-get-and-post-requests/