{"action":"opened","issue":{"url":"https://api.github.com/repos/inaka/apns4erl/issues/77","labels_url":"https://api.github.com/repos/inaka/apns4erl/issues/77/labels{/name}","comments_url":"https://api.github.com/repos/inaka/apns4erl/issues/77/comments","events_url":"https://api.github.com/repos/inaka/apns4erl/issues/77/events","html_url":"https://github.com/inaka/apns4erl/issues/77","id":107848351,"number":77,"title":"Add synchronous calls for sending messages.","user":{"login":"tomekowal","id":907415,"avatar_url":"https://avatars.githubusercontent.com/u/907415?v=3","gravatar_id":"","url":"https://api.github.com/users/tomekowal","html_url":"https://github.com/tomekowal","followers_url":"https://api.github.com/users/tomekowal/followers","following_url":"https://api.github.com/users/tomekowal/following{/other_user}","gists_url":"https://api.github.com/users/tomekowal/gists{/gist_id}","starred_url":"https://api.github.com/users/tomekowal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomekowal/subscriptions","organizations_url":"https://api.github.com/users/tomekowal/orgs","repos_url":"https://api.github.com/users/tomekowal/repos","events_url":"https://api.github.com/users/tomekowal/events{/privacy}","received_events_url":"https://api.github.com/users/tomekowal/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-09-23T04:39:40Z","updated_at":"2015-09-23T04:39:40Z","closed_at":null,"body":"Sending too many devices with wrong device ids causes closing socket by APNS server, which in turn crashes `apns_connection` `gen_server`.\r\n\r\nThe carsh is not a big deal, because `apns_connection` is supervised, but `send` function is using `gen_server:cast`, so when the server crashes, all messages that were queued in process mailbox are gone and we don't know, what messages were there.\r\n\r\nMy solution to this problem would be to add `gen_server:call` doing exactly the same thing - sending messages, but because it is synchronous, we might be sure that:\r\n- we know, that it crashed and we can retry sending the message after it gets restarted\r\n- no other messages hidden in mailbox are lost (if we are not using cast)\r\n\r\nIf you think, this is a good idea, I can make a pull request, but it would be great to fix #71 before that.\r\nOtherwise, it is a little bit hard to test, if everything is working correctly.\r\n\r\nIf you can think of a better solution, I am open.\r\n\r\n"}}