Can't connect to production Apple Push Notific

2020-06-23 05:09发布

问题:

We had no problem sending notifications to provisioned devices using the development certification and gateway.sandbox.push.apple.com. But now now that our app is in the store, it appears we can't even connect to the production apn server (gateway.push.apple.com) to send pushes, even when we're using the machines that created the certificates in the first place.

We've run this through PushMeBaby and it looks like the connection to gateway.push.apple.com is getting refused. When it executes the handshake ( SSLHandshake(context) ) the result is error code -9044, or errSSLConnectionRefused - The peer dropped the connection before responding.

I know enough about ssl and encryption to know that I don't know a thing, but I'm pretty sure that the issue is (or starts with) our production SSL cert. Push notification is enabled for production in the iPhone portal (we have a green light). The certificate has been installed on the machine running PushMeBaby and I see both the certificate and the signing key in my keychain. When I exported the development push certificate and used it in PushMeBaby, I was able to connect (and send pushes) no problem. But with the production cert, We get nowhere. We've repeatedly revoked and recreated both the dev cert and the prod cert on two separate computers, so if this is human error, we're doing it repeatedly.

One thing that may be a factor is that I have the "team agent" key on my keychain, but I'm not her. I can and have submitted binaries to the App store without any issue.

Also, we've not set up a provisioning profile after creating the production cert. I'm not sure if that's a factor, but I can't see how it might be for an in-store app.

I sure hope someone has some ideas, because I'm out of them!

回答1:

Yes, I've solved this error. I lost a few days finding the solution.

The problem is in the line:

result = SSLSetPeerDomainName(context, "gateway.sandbox.push.apple.com", 30); 

NSLog(@"SSLSetPeerDomainName(): %d", result);

You have to change the port to number 30. This solves the problem.



回答2:

As the documentation said it exists 2 certificates and 2 IP address for the push notification:

  • Sandbox: gateway.sandbox.push.apple.com, port 2195. (for the development)
  • Production: gateway.push.apple.com, port 2195. (for the release)

You always use the gateway for the development. Try to use the other gateway (for the production).

For more information see here: Provisioning and Development



回答3:

Similar problem was happening in our tests because we were trying to use developer device token instead of a production one.