Comments (34)
This is very strange. Are you able to compare the data generated by node-apn to that generated by the PHP code? I can't immediately think of a reason which might cause this.
from node-apn.
Ah, i guess I found the reason.
When I try to send multiple push notifications and if one of the hextoken is invalid, the following will not get through as well.
For example,
var strBadHextoken = 'xxx';
var strGoodHextoken = 'yyy';
var myDevice1 = new apns.Device(strBadHextoken);
var myDevice2 = new apns.Device(strGoodHextoken);
var note = new apns.Notification();
note.badge = 1;
note.sound = "ping.aiff";
note.alert = "You have a new message";
note.payload = {'messageFrom': 'Tester'};
note.device = myDevice1;
apnsConnection.sendNotification(note);
note.device = myDevice2;
apnsConnection.sendNotification(note);
In this case, myDevice2 will not receive any push notification.
Any idea how to solve this?
Thank you!
from node-apn.
I have exactly the same issue :/
from node-apn.
I am currently rewriting the connection handling code. I hope to have something available at the weekend which should fix this problem.
from node-apn.
Nice !
I'll be testing whenever you want... for more than 26000 pushes :)
from node-apn.
Thank you very much :)
from node-apn.
The problem is that you are reusing a notification object:
note.device = myDevice1;
apnsConnection.sendNotification(note);
note.device = myDevice2;
apnsConnection.sendNotification(note);
Try creating a notification object for each device. I'm still trying to decide on a good solution for sending the same notification to multiple devices
from node-apn.
In v1.2.0 notifications will have a .clone(device)
method to clone a notification to send to multiple devices.
from node-apn.
apnsConnection.sendNotification(note.clone(myDevice1));
apnsConnection.sendNotification(note.clone(myDevice2));
from node-apn.
Hi Argon, first, thanks a lot for this great node module.
Sadly I'm having the same issue. I'm sending a new notification to each of 50 devices. But as soon as there is a invalid device, the notifications won't get delivered. In 50% of my tests I will get this error with node crashing:
node.js:201 throw e; // process.nextTick error, or 'error' event on first tick ^ Error: write EPIPE at errnoException (net.js:646:11) at Object.afterWrite [as oncomplete] (net.js:480:18)
from node-apn.
Can you confirm which version of the code you're running?
from node-apn.
Sorry, I'm running the latest version: 1.2.0 but had the same issue with 1.1.
If I limit the devices to a smaller number, e.g. 5, and having one with a wrong token, everything seems to work.
from node-apn.
Are you able to consistently reproduce this problem? I have some ideas about how to handle this, would you be willing to try my changes?
from node-apn.
Yes, I can reproduce this every time. That would be great!
from node-apn.
Could you run your application with NODE_DEBUG=tls,net node app.js
and post the result to allow me to pinpoint the problem further?
from node-apn.
Thanks a lot for looking into this. You can find the log here: http://pastebin.com/4r3sLUMY
from node-apn.
here you can find my node source: http://pastebin.com/xpBksrnd
from node-apn.
There is another problem: If I manually remove all invalid tokens and send the push message to all (about 2300) devices I don't get any errors but the push message is never received by my device which is one of the last in the list.
from node-apn.
In connection.js: If I replace "this.socket.destroySoon()" with "this.socket.destroy()" I don't get any EPIPE errors and node is not killed but the push message still won't get delivered to the following devices.
from node-apn.
could you pull the copy of the module on the 'develop' branch, npm install debug
and run DEBUG=apn NODE_DEBUG=tls,net node app.js
and post your results. I have changed destroySoon to destroy and made a few small changes which may fix your problem in addition to adding logging.
from node-apn.
No more node kills but still no push messages after a device with a invalid token: http://pastebin.com/nZhViGNa
I think that the queue is not processed again after an error occurs.
Isn't this strange?
Fri, 22 Jun 2012 22:31:11 GMT apn Restarting connection NET: destroy NET: close Fri, 22 Jun 2012 22:31:11 GMT apn Sending notification Fri, 22 Jun 2012 22:31:11 GMT apn Sending notification
from node-apn.
Sorry to take up so much of your time, I think I found the problem, I made too many changes! Can you try the latest on develop and see if it helps. I really appreciate it.
from node-apn.
I really appreciate all of your work. So don't thank me. I have to thank you :)
But I'm sorry to tell you that the latest update don't fix the problem. Still no push message on the device :(
Current debug log: http://pastebin.com/SyyWGkeW
from node-apn.
What I don't get is why it stops at the second try:
apn Sending notification +0ms apn Sending notification +0ms apn Sending notification +0ms apn Notification 0 caused an error: 8 +111ms apn Raising error: 8 +1ms { encoding: 'utf8', payload: { aps: { badge: 1 } }, expiry: 0, identifier: 0, alert: undefined, badge: 1, sound: undefined, newsstandAvailable: undefined, device: { token: }, _uid: 0 } APNS ERROR: 8 { encoding: 'utf8', payload: { aps: { badge: 1 } }, expiry: 0, identifier: 0, alert: undefined, badge: 1, sound: undefined, newsstandAvailable: undefined, device: { token: }, _uid: 0 } apn Buffering 9 notifications +1ms apn Destroying connection +0ms apn Restarting connection +4ms apn Notification queue has 9 items, resending the first +0ms apn Initialising connection +0ms NET: destroy NET: close NET: connect: find host gateway.push.apple.com NET: afterConnect NET: Drain the connect queue apn Connection established +508ms apn Sending notification +1ms
from node-apn.
The first device (notification) on the second round gets the push message successfully but it won't continue to process the queue.
from node-apn.
Can you replace the socketDrained method in connection.js with the following and try again, when it finishes sending one notification it is supposed to process the next but it doesn't seem to be doing this. Need to establish the point it is getting to
Connection.prototype.socketDrained = function() {
debug("Socket drained");
if (this.socket && (this.socket.socket.bufferSize != 0 || !this.socket.writable)) {
return;
}
debug("Socket writeable");
if (this.notificationBuffer.length > 0) {
debug("Sending notification from buffer");
this.sendNotification(this.notificationBuffer.shift());
}
};
from node-apn.
Still no change: http://pastebin.com/Z5k2fENh
from node-apn.
I think I have found the problem. Just making sure I code the change correctly.
from node-apn.
I have pushed a (hopeful) fix to the develop branch. Please let me know how things go.
from node-apn.
Thanks so much. Works like a charm, now :)
from node-apn.
Can you leave the debug logs in code? I find it really helpful to see whats going on.
from node-apn.
Great, I'll merge this into the next release. I may change the debugging a little but it was always my intention to introduce them to the next release.
from node-apn.
@argon could you add a comment what the problem was and how you fixed this?
from node-apn.
I have made many changes since this issue to address reliability, including a change currently on "develop" which should also tackle the EPIPE problem at the source. If you're having a specific problem which you think is related to this could you please open a new issue so I can track it properly.
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.