Code Monkey home page Code Monkey logo

Comments (11)

argon avatar argon commented on June 12, 2024

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.

dgthistle avatar dgthistle commented on June 12, 2024

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.

argon avatar argon commented on June 12, 2024

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.

argon avatar argon commented on June 12, 2024

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.

dgthistle avatar dgthistle commented on June 12, 2024

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.

dgthistle avatar dgthistle commented on June 12, 2024

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.

dgthistle avatar dgthistle commented on June 12, 2024

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.

dgthistle avatar dgthistle commented on June 12, 2024

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.

argon avatar argon commented on June 12, 2024

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.

argon avatar argon commented on June 12, 2024

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.

argon avatar argon commented on June 12, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.