{"action":"created","issue":{"url":"https://api.github.com/repos/argon/node-apn/issues/388","repository_url":"https://api.github.com/repos/argon/node-apn","labels_url":"https://api.github.com/repos/argon/node-apn/issues/388/labels{/name}","comments_url":"https://api.github.com/repos/argon/node-apn/issues/388/comments","events_url":"https://api.github.com/repos/argon/node-apn/issues/388/events","html_url":"https://github.com/argon/node-apn/issues/388","id":155942452,"number":388,"title":"Closing Connections & Moving On","user":{"login":"medoix","id":149519,"avatar_url":"https://avatars.githubusercontent.com/u/149519?v=3","gravatar_id":"","url":"https://api.github.com/users/medoix","html_url":"https://github.com/medoix","followers_url":"https://api.github.com/users/medoix/followers","following_url":"https://api.github.com/users/medoix/following{/other_user}","gists_url":"https://api.github.com/users/medoix/gists{/gist_id}","starred_url":"https://api.github.com/users/medoix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/medoix/subscriptions","organizations_url":"https://api.github.com/users/medoix/orgs","repos_url":"https://api.github.com/users/medoix/repos","events_url":"https://api.github.com/users/medoix/events{/privacy}","received_events_url":"https://api.github.com/users/medoix/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-05-20T11:26:21Z","updated_at":"2016-05-21T02:11:36Z","closed_at":null,"body":"So i am trying everything i can find to close the connection after notifications are sent but nothing i do works and the script just sits there waiting for something and not moving on to my next logic section.\r\n\r\nI have tried the connetionTimeout option and also the connection.shutdown() functions it still sits in a running state.\r\n\r\nThe code i have currently is below\r\n```\r\nfor(d in device){\r\n              console.log('Device ' + d + ' Type: ' + JSON.stringify(device[d].type));\r\n              console.log('Device ' + d + ' ID: ' + JSON.stringify(device[d].devId));\r\n              if(device[d].type == \"ios\"){\r\n                var myDevice = new apn.Device(device[d].devId);\r\n                var note = new apn.Notification();\r\n                note.expiry = Math.floor(Date.now() / 1000) + 3600; // Expires 1 hour from now.\r\n                note.badge = 1;\r\n                note.sound = \"ping.aiff\";\r\n                note.alert = \"\\uD83D\\uDCE7 \\u2709 You have a new message\";\r\n                note.payload = {'messageFrom': 'Caroline'};\r\n                apnConnection.pushNotification(note, myDevice);\r\n                console.log('Push Sent To: ' + device[d].devId);\r\n              } else if(device[d].type == \"android\"){\r\n                registrationIds.push(device[d].devId);\r\n              }\r\n            }\r\n            apnConnection.once('completed', function () {\r\n              console.log(\"pending queue is empty\");\r\n              apnConnection.shutdown();\r\n            });\r\n```\r\n\r\nI see the text \"pending queue is empty\" but the connections do not shutdown and the script just sits waiting instead of moving on to the next section...."},"comment":{"url":"https://api.github.com/repos/argon/node-apn/issues/comments/220753158","html_url":"https://github.com/argon/node-apn/issues/388#issuecomment-220753158","issue_url":"https://api.github.com/repos/argon/node-apn/issues/388","id":220753158,"user":{"login":"medoix","id":149519,"avatar_url":"https://avatars.githubusercontent.com/u/149519?v=3","gravatar_id":"","url":"https://api.github.com/users/medoix","html_url":"https://github.com/medoix","followers_url":"https://api.github.com/users/medoix/followers","following_url":"https://api.github.com/users/medoix/following{/other_user}","gists_url":"https://api.github.com/users/medoix/gists{/gist_id}","starred_url":"https://api.github.com/users/medoix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/medoix/subscriptions","organizations_url":"https://api.github.com/users/medoix/orgs","repos_url":"https://api.github.com/users/medoix/repos","events_url":"https://api.github.com/users/medoix/events{/privacy}","received_events_url":"https://api.github.com/users/medoix/received_events","type":"User","site_admin":false},"created_at":"2016-05-21T02:11:36Z","updated_at":"2016-05-21T02:11:36Z","body":"<img width=\"613\" alt=\"screen shot 2016-05-21 at 12 10 30 pm\" src=\"https://cloud.githubusercontent.com/assets/149519/15445846/103fc294-1f4d-11e6-8d27-c26b8c49d6f6.png\">\r\nScreenshot of terminal to help explain what happens, just sits even though the apnConnection.shutdown(); command is called..."}}
{"actor":{"display_login":"medoix"}}