Hi, I've been trying to send a push notification request to my pass installed in apple wallet. I've used recommendations from the documentation https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns.
Am currently using Node and Axios to make the request and below are my code and error response.
Request code
const client = axios.create({
method: "PORT",
baseURL: "http://api.push.apple.com:443/",
timeout: 10 * 60000,
httpsAgent: new https.Agent({
keepAlive: false,
maxSockets: Infinity,
}),
httpAgent: new http.Agent({
keepAlive: false,
maxSockets: Infinity,
}),
headers: {
Authorization: `Bearer ${authorizationToken}`,
},
});
client
.post(`http://api.push.apple.com:443/3/device/${data[4]}`, {
serialNumbers: ["1670976404943"],
updated: "1351981923",
})
.then((e) => {
console.log("Wallet query success: ", e);
response.status(200).json({
message: "Testing successfull",
status: true,
});
})
.catch((e) => {
console.error("Wallet query failure: ", e);
response.status(200).json({
message: "Testing unsuccessfull",
status: false,
});
});
Error response
AxiosError: socket hang up
code: 'ECONNRESET',
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: [ 'xhr', 'http' ],
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 600000,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: { FormData: [Function], Blob: null },
validateStatus: [Function: validateStatus],
headers: AxiosHeaders {
Accept: 'application/json, text/plain, */*',
'Content-Type': 'application/json',
Authorization: 'Bearer ${token},
'User-Agent': 'axios/1.2.1',
'Content-Length': '58',
'Accept-Encoding': 'gzip, compress, deflate, br'
},
method: 'post',
baseURL: 'http://api.push.apple.com:443/',
httpAgent: Agent {
_events: [Object: null prototype],
_eventsCount: 2,
_maxListeners: undefined,
defaultPort: 80,
protocol: 'http:',
options: [Object: null prototype],
requests: [Object: null prototype] {},
sockets: [Object: null prototype],
freeSockets: [Object: null prototype] {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256,
scheduling: 'lifo',
maxTotalSockets: Infinity,
totalSocketCount: 1,
[Symbol(kCapture)]: false
},
url: 'http://api.push.apple.com:443/3/device/1cf7e28073c081aa4ff1af4a01a448ee',
data: '{"serialNumbers":["1670976404943"],"updated":"1351981923"}'
},
cause: Error: socket hang up
at connResetException (node:internal/errors:704:14)
at Socket.socketOnEnd (node:_http_client:505:23)
at Socket.emit (node:events:525:35)
at endReadableNT (node:internal/streams/readable:1358:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'ECONNRESET'
}
}
I would appreciate if anyone can help me debug.