groupme / em-apn

EventMachine'd Apple Push Notifications
MIT License
48 stars 15 forks source link

Automattic reconnect seems to be broken #5

Closed squeedee closed 13 years ago

squeedee commented 13 years ago

When I send an invalid token i get:

I, [2011-11-11T11:56:32.038103 #41783] INFO -- : TOKEN=df6f35d25288c0be4ed6e91cc404439c1b79b02999d662c7d65b139289bcbdc0 I, [2011-11-11T11:56:32.173585 #41783] INFO -- : CODE=8 ID=256 DESC=Invalid token Got data: [8, 8, 256]

The last line is my on_receipt output.

If i then send a valid token i see

I, [2011-11-11T11:56:54.579125 #41783] INFO -- : TOKEN=520b12a526c0788425e5c9f6a7fd069eaf99d5ddda296fad2317b0e2dc9e44aa

and nothing further.

If i then send a broken token again, i do not get a reciept.

This makes me think that em-apn is not reestablishing the connection, and not letting us know it's down.

daveyeu commented 13 years ago

Are you using the EM::APN.push interface or the Client directly?

squeedee commented 13 years ago

https://gist.github.com/1356610

daveyeu commented 13 years ago

Thanks for the gist. Sadly, the client does not reconnect automatically. There is re-connection logic, but it's actually handled in the higher-level EM::APN.push interface. That simplified interface keeps around a memoized Client instance, and when it detects that it has disconnected, simply creates a new one.

Why not just call reconnect inside unbind? IIRC, if a high rate of messages were being delivered and the connection dropped and re-connected, there was actually a strong possibility of messages being lost. I'm not sure why, but I'm pretty sure I was seeing that. Creating a new instance on connection failures was actually more reliable.

All that said, I haven't looked into it in a while. Perhaps the latest EM handles reconnects more gracefully. Maybe some sort of deferrable hanging on the connection status would solve things.

daveyeu commented 13 years ago

git show e1d72351b043c39bf157eb35b9c3cd1e3bab9468. Ah, nostalgia.

squeedee commented 13 years ago

I'll just do what you're doing in my code. All good - thankyou for your responsiveness. Can I ask, are groupme behind this? is it/will it be in their production systems?

daveyeu commented 13 years ago

Yup, this was written for GroupMe and is used in production.