{"action":"created","issue":{"url":"https://api.github.com/repos/grocer/grocer/issues/14","labels_url":"https://api.github.com/repos/grocer/grocer/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/grocer/grocer/issues/14/comments","events_url":"https://api.github.com/repos/grocer/grocer/issues/14/events","html_url":"https://github.com/grocer/grocer/issues/14","id":5225903,"number":14,"title":"Socket connection drops next notification if invalid notification is sent","user":{"login":"kyledrake","id":28153,"avatar_url":"https://avatars.githubusercontent.com/u/28153?v=3","gravatar_id":"","url":"https://api.github.com/users/kyledrake","html_url":"https://github.com/kyledrake","followers_url":"https://api.github.com/users/kyledrake/followers","following_url":"https://api.github.com/users/kyledrake/following{/other_user}","gists_url":"https://api.github.com/users/kyledrake/gists{/gist_id}","starred_url":"https://api.github.com/users/kyledrake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kyledrake/subscriptions","organizations_url":"https://api.github.com/users/kyledrake/orgs","repos_url":"https://api.github.com/users/kyledrake/repos","events_url":"https://api.github.com/users/kyledrake/events{/privacy}","received_events_url":"https://api.github.com/users/kyledrake/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/grocer/grocer/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/grocer/grocer/milestones/2","html_url":"https://github.com/grocer/grocer/milestones/1.0.0%20Release","labels_url":"https://api.github.com/repos/grocer/grocer/milestones/2/labels","id":287156,"number":2,"title":"1.0.0 Release","description":"It would be nice to shoot for a \"completed\" major point release. Here are some things that should be included.","creator":{"login":"vanstee","id":228734,"avatar_url":"https://avatars.githubusercontent.com/u/228734?v=3","gravatar_id":"","url":"https://api.github.com/users/vanstee","html_url":"https://github.com/vanstee","followers_url":"https://api.github.com/users/vanstee/followers","following_url":"https://api.github.com/users/vanstee/following{/other_user}","gists_url":"https://api.github.com/users/vanstee/gists{/gist_id}","starred_url":"https://api.github.com/users/vanstee/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vanstee/subscriptions","organizations_url":"https://api.github.com/users/vanstee/orgs","repos_url":"https://api.github.com/users/vanstee/repos","events_url":"https://api.github.com/users/vanstee/events{/privacy}","received_events_url":"https://api.github.com/users/vanstee/received_events","type":"User","site_admin":false},"open_issues":6,"closed_issues":3,"state":"open","created_at":"2013-03-12T20:36:43Z","updated_at":"2013-03-18T15:26:56Z","due_on":null,"closed_at":null},"comments":44,"created_at":"2012-06-22T23:44:01Z","updated_at":"2016-01-13T17:45:24Z","closed_at":null,"body":"So, this is the problem I ran into on Lead Zeppelin (https://github.com/geoloqi/lead_zeppelin). It's kindof a big problem right now, and I haven't figured out a graceful way to fix it yet.\n\nIf you send an illegit message (such as a message with a bad device token), the connection will drop without throwing an exception for the next message, and that next message will effectively be dropped.\n\nExample:\n\n```ruby\n\npusher = Grocer.pusher(certificate: \"/path/to/validcert.pem\")\nnotification = Grocer::Notification.new(device_token: \"valid device token\", alert: 'this will work')\npusher.push(notification)\nnotification = Grocer::Notification.new(device_token: \"bad device token\", alert: 'this will fail, as expected')\npusher.push(notification)\nnotification = Grocer::Notification.new(device_token: \"valid device token\", alert: 'THIS WILL UNEXPECTEDLY FAIL WITH NO EXCEPTIONS OR WARNINGS')\npusher.push(notification)\nnotification = Grocer::Notification.new(device_token: \"valid device token\", alert: 'this will work because an exception will be thrown, reconnecting the socket')\npusher.push(notification)\n\n```\n\nI don't know what the source of this problem is.. whether it's something in Ruby, something on Apple's APNS servers, or some sort of buffering issue, or what.\n\nI worked around this problem by putting in an IO.select to wait for a specific period of time, to see if the socket becomes available for reading. With the enhanced protocol, being readable indicates that there was an error. But the only way to do this is to wait for a response before using it again, due to the silent failure. But this solution sucks, because it slows everything down.\n\nYou can see the implementation of that IO.select here: https://github.com/geoloqi/lead_zeppelin/blob/master/lib/lead_zeppelin/apns/gateway.rb#L96\n\nThe solution I was pondering to deal with this problem was to switch back to the version 0 protocol, but then of course you don't get the enhanced error response, which also kindof sucks.\n\n**The real solution would be for APNS to send a confirmation bit like they should, or drop the connection correctly**... but that's not going to happen anytime soon. Really at a loss for how to solve this."},"comment":{"url":"https://api.github.com/repos/grocer/grocer/issues/comments/171376662","html_url":"https://github.com/grocer/grocer/issues/14#issuecomment-171376662","issue_url":"https://api.github.com/repos/grocer/grocer/issues/14","id":171376662,"user":{"login":"idyll","id":4642,"avatar_url":"https://avatars.githubusercontent.com/u/4642?v=3","gravatar_id":"","url":"https://api.github.com/users/idyll","html_url":"https://github.com/idyll","followers_url":"https://api.github.com/users/idyll/followers","following_url":"https://api.github.com/users/idyll/following{/other_user}","gists_url":"https://api.github.com/users/idyll/gists{/gist_id}","starred_url":"https://api.github.com/users/idyll/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/idyll/subscriptions","organizations_url":"https://api.github.com/users/idyll/orgs","repos_url":"https://api.github.com/users/idyll/repos","events_url":"https://api.github.com/users/idyll/events{/privacy}","received_events_url":"https://api.github.com/users/idyll/received_events","type":"User","site_admin":false},"created_at":"2016-01-13T17:45:24Z","updated_at":"2016-01-13T17:45:24Z","body":"With the changes to push tokens in iOS 9.0 this bug has made grocer completely unreliable.\r\n\r\niOS 9.0 results in a new push token being generated when an app is deleted then re-installed. The old token is invalidated. Often it will take  the feedback services hours to report it, but Apple rejects it pretty much immediately.\r\n\r\nI think that if there's no clear solution to this the README should be updated with a warning.\r\n\r\nThe project simply isn't usable without this being fixed."}}