Comments (11)
Thanks for highlighting this, I was always a bit suspicious of my use of self.socket.pair.on(), its looks like maybe I should use the callback on tls.connect which I somehow missed when I ported to 0.4, I shall investigate and get it fixed ASAP.
from node-apn.
Thanks Argon! Sounds like the right approach. I'd be more than happy to help with the fix or testing the fix. Just let me know.
from node-apn.
Well, I should be using the callback on tls.connect() but that is not the problem. The error is within the callback and for some reason self.socket is undefined so the property authorized cannot be read. Maybe the object is getting destroyed when it cannot connect but further investigation is required.
from node-apn.
I have been unable to replicate the problem and I can't quite figure out what could be causing the problem.
Are you able to provide any example to reliably replicate the problem?
from node-apn.
I have finally found a fairly reliable way to reproduce by forcing multiple InvalidToken error conditions when sending a push notification (I think my original assumption that it was related to an apn service connection error is wrong). In my case, the token is actually a developer profile token being sent to the production gateway, but I presume it'll work for any invalid token.
I believe the error occurs in other "valid" cases but haven't confirmed yet. Will do when I find another case.
from node-apn.
In my development environment, I get a different exception but along the same lines:
assert.js:81
throw new assert.AssertionError({
^
AssertionError: true == false
at CleartextStream.readyState (net.js:285:7)
at [object Object].sendNotification (/Users/dgthistle/local/node/lib/node_modules/apn/lib/apn.js:118:47)
at /Users/dgthistle/local/node/lib/node_modules/apn/lib/apn.js:160:10
at CleartextStream. (/Users/dgthistle/local/node/lib/node_modules/apn/lib/apn.js:51:43)
at CleartextStream.emit (events.js:64:17)
at CleartextStream._push (tls.js:313:12)
at SecurePair.cycle (tls.js:594:20)
at EncryptedStream.write (tls.js:124:13)
at Socket.ondata (stream.js:36:26)
at Socket.emit (events.js:64:17)
Haven't quite grasped why the path is different. I simply force two InvalidToken (8) errors in a row to generate this.
from node-apn.
OK. Scratch that last comment... I updated to the latest version of node (v4.11) and I'm back to the same exception:
/Users/dgthistle/local/node/lib/node_modules/apn/lib/apn.js:50
self.socket.pair.on('secure', function () { if(!self.socket.authorized) { th
^
TypeError: Cannot read property 'authorized' of undefined
at SecurePair. (/Users/dgthistle/local/node/lib/node_modules/apn/lib/apn.js:50:62)
at SecurePair.emit (events.js:81:20)
at SecurePair.maybeInitFinished (tls.js:601:10)
at CleartextStream._push (tls.js:269:17)
at SecurePair.cycle (tls.js:577:20)
at EncryptedStream.write (tls.js:96:13)
at Socket.ondata (stream.js:36:26)
at Socket.emit (events.js:64:17)
at Socket._onReadable (net.js:678:14)
at IOWatcher.onReadable as callback
The exception in the last comment was related to nodejs/node-v0.x-archive#1069 and was fixed with an upgrade.
from node-apn.
Assuming this only happens when the access token is invalid, I'll submit a pull request that just ignores the situation. If I see it occurring in other circumstances I'll let you know.
from node-apn.
The fact that it happens when the access code is invalid is interesting, I am currently running through the code to find the possible problem.
from node-apn.
I have succeeded in replicating the problem. WIth device token being incorrect.
var device = new APNService.device(token);
var alert = "Message received from node-apn!";
var note = new APNService.notification();
note.alert = alert;
note.badge = 1;
note.device = device;
var note2 = new APNService.notification();
note2.alert = alert;
note2.device = device;
try {
service.sendNotification(note);
service.sendNotification(note2);
}
catch (e) {
console.log(e);
}
from node-apn.
I have pushed a patch to the 'develop' branch for this issue. Would you mind checking it out to ensure it fixes the problem at your end?
from node-apn.
Related Issues (20)
- 1
- Error: Socket unusable after connection. Hint: You may be using a certificate for the wrong environment HOT 1
- Deploying to Flywheel workflow failing saying inputs not valid
- ERR_CRYPTO_OPERATION_FAILED HOT 3
- High Vulnerability on node-forge-0.7.6.tgz (Vulnerable Library)
- iOS Push Notification Error: {reason: 'TopicDisallowed'} HOT 3
- How to send Communication Notifications? HOT 5
- Critical security vuln: jsonwebtoken HOT 2
- Live Activity Support
- How to use P12 files to send pushes HOT 8
- Send Push Notification To Apple Watch
- apn write failed: GOAWAY: PROTOCOL_ERROR Stream 5 does not exist HOT 1
- The future of `node-apn`
- Show In Foreground?
- Dynamically or using RESTful API to add device
- What is the right way to send a silent push notification(content-available = 1) in 2024?
- Port from http to fetch
- Is there a way to retrieve the `aps-unique-id` return header value?
- Is this package abandoned?
- is it possible to send push to multiple devices with multiple payloads using node-apn without looping?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-apn.