{"action":"created","issue":{"url":"https://api.github.com/repos/web-push-libs/web-push/issues/237","repository_url":"https://api.github.com/repos/web-push-libs/web-push","labels_url":"https://api.github.com/repos/web-push-libs/web-push/issues/237/labels{/name}","comments_url":"https://api.github.com/repos/web-push-libs/web-push/issues/237/comments","events_url":"https://api.github.com/repos/web-push-libs/web-push/issues/237/events","html_url":"https://github.com/web-push-libs/web-push/issues/237","id":181502841,"number":237,"title":"WebPushError: Received unexpected response code, statusCode: 400, UnauthorizedRegistration","user":{"login":"srodovinsky","id":22420844,"avatar_url":"https://avatars.githubusercontent.com/u/22420844?v=3","gravatar_id":"","url":"https://api.github.com/users/srodovinsky","html_url":"https://github.com/srodovinsky","followers_url":"https://api.github.com/users/srodovinsky/followers","following_url":"https://api.github.com/users/srodovinsky/following{/other_user}","gists_url":"https://api.github.com/users/srodovinsky/gists{/gist_id}","starred_url":"https://api.github.com/users/srodovinsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srodovinsky/subscriptions","organizations_url":"https://api.github.com/users/srodovinsky/orgs","repos_url":"https://api.github.com/users/srodovinsky/repos","events_url":"https://api.github.com/users/srodovinsky/events{/privacy}","received_events_url":"https://api.github.com/users/srodovinsky/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-06T19:20:50Z","updated_at":"2016-10-06T22:44:56Z","closed_at":null,"body":"Hi,\r\n\r\nI am sending a batch of about 15,000 web push notifications to my website subscribers. Only about half of them go out fine. Rest of the pushes fail with the following error:\r\n\r\n```\r\n{ [WebPushError: Received unexpected response code]\r\n  name: 'WebPushError',\r\n  message: 'Received unexpected response code',\r\n  statusCode: 400,\r\n  headers: \r\n   { 'content-type': 'text/html; charset=UTF-8',\r\n     date: 'Wed, 05 Oct 2016 14:58:14 GMT',\r\n     expires: 'Wed, 05 Oct 2016 14:58:14 GMT',\r\n     'cache-control': 'private, max-age=0',\r\n     'x-content-type-options': 'nosniff',\r\n     'x-frame-options': 'SAMEORIGIN',\r\n     'x-xss-protection': '1; mode=block',\r\n     server: 'GSE',\r\n     'alt-svc': 'quic=\":443\"; ma=2592000; v=\"36,35,34,33,32\"',\r\n     'accept-ranges': 'none',\r\n     vary: 'Accept-Encoding',\r\n     connection: 'close' },\r\n  body: '<HTML>\\n<HEAD>\\n<TITLE>UnauthorizedRegistration</TITLE>\\n</HEAD>\\n<BODY BGCOLOR=\"#FFFFFF\" TEXT=\"#000000\">\\n<H1>UnauthorizedRegistration</H1>\\n<H2>Error 400</H2>\\n</BODY>\\n</HTML>\\n' }\r\n```\r\n\r\nWould you be able to help me to resolve this one?"},"comment":{"url":"https://api.github.com/repos/web-push-libs/web-push/issues/comments/252109403","html_url":"https://github.com/web-push-libs/web-push/issues/237#issuecomment-252109403","issue_url":"https://api.github.com/repos/web-push-libs/web-push/issues/237","id":252109403,"user":{"login":"srodovinsky","id":22420844,"avatar_url":"https://avatars.githubusercontent.com/u/22420844?v=3","gravatar_id":"","url":"https://api.github.com/users/srodovinsky","html_url":"https://github.com/srodovinsky","followers_url":"https://api.github.com/users/srodovinsky/followers","following_url":"https://api.github.com/users/srodovinsky/following{/other_user}","gists_url":"https://api.github.com/users/srodovinsky/gists{/gist_id}","starred_url":"https://api.github.com/users/srodovinsky/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srodovinsky/subscriptions","organizations_url":"https://api.github.com/users/srodovinsky/orgs","repos_url":"https://api.github.com/users/srodovinsky/repos","events_url":"https://api.github.com/users/srodovinsky/events{/privacy}","received_events_url":"https://api.github.com/users/srodovinsky/received_events","type":"User","site_admin":false},"created_at":"2016-10-06T22:44:56Z","updated_at":"2016-10-06T22:44:56Z","body":"Thanks for looking into it.\r\n\r\nI don't see any pattern yet, but will continue to investigate. All the subscribers are from browsers Chrome and Firefox, so I would assume they are GCM subscribers.\r\n\r\nI am using version 3.0.0 of the web-push library and my code looks like this:\r\n\r\n`const webpush = require('web-push');`\r\n...\r\n`const sub = {\r\n            \"keys\" : {\r\n                \"auth\" : \"......\",\r\n                \"p256dh\" : \"...........................................\"\r\n            },\r\n            \"endpoint\" : \"https://android.googleapis.com/gcm/send/.............................................................\"\r\n        };`\r\n...\r\n`    const params = {\r\n        title: options.title,\r\n        message: options.message,\r\n        icon: '/api/push/icon/' + campaignId, //icon served by my API\r\n        tag: 'message-tag'\r\n    };`\r\n...\r\n`webpush.setGCMAPIKey('AIzaSyDeMy9BOmTN0b9PLRzECkEkP4zOMebLVkU');`\r\n...\r\n`webpush.sendNotification(sub, new Buffer(JSON.stringify(params), 'utf8'))\r\n             .then(\r\n                 function (data) {\r\n                     return callback(null, data);\r\n                 },\r\n                 function (err) {\r\n                     return callback(err, null);\r\n                 }\r\n             )\r\n             .catch(function (ex) {\r\n                 return callback(new Error(ex), null);\r\n             }\r\n         );`\r\n\r\nPlease let me know if any additional information might be helpful"}}
{"actor":{"display_login":"srodovinsky"}}