Invalid token for some devices

gorodezkiy picture gorodezkiy · Apr 10, 2012 · Viewed 8k times · Source

given:

  • working iPod application
  • The server side in php (modified easyapns).

I'm sending requests in the sandbox ssl://gateway.sandbox.push.apple.com:2195 If I'm sending a request to ssl://gateway.push.apple.com:2195, no errors returned, but the notification did not reach. In this case if I'm sending totally wrong device token (e.g. 12345), the APNs still didn't return error.

Problem: APN returns status_code => 8 (for explanation of the docks: Invalid token) to the inquiry Enhanced notification format, and returns an error code for a 4 out of 5 tokens with 5 devices.

I have correct dev crtificate, at least so says iPod's app developer which sent that certificate to me. And the iPod's app developer argues that application is sending correct dev token each time (I don't know how to check device token without mac and developer tools).

Checked:

  • The server ports 2195,2196 are open
  • My router settings through which iPod connected to the network is correct (and port 5223 for receiving is open) - I tested on "iPusher" and "iPush test" apps
  • Connection to the APN is successful
  • Tried to send from the local machine
  • Tried to send from the VPS
  • Checked

Answer

ostergaard picture ostergaard · May 7, 2012

When I had this problem it turned out to be because the key and cert didn't match. Try connecting using openssl:

openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert cert.pem -key key.pem

Until that spews out a pile of stuff starting with 'CONNECTED' you're not connecting properly.