joekarl / go-libapns Goto Github PK
View Code? Open in Web Editor NEWLow level APNS library for go
License: MIT License
Low level APNS library for go
License: MIT License
There's no check to see if the error payload is actually set or not here https://github.com/joekarl/go-libapns/blob/master/connection.go#L316-L328.
Solely looking at the error code of the apple error is probably not a great idea. Need to couple with looking at the appleError.MessageID
as well and start the payloadIdCounter
at 1 instead of 0.
When priority is set, APNS rejects payload and closes connection. Issue is in connection.go line 479 writing priority data length.
binary.Write(c.inFlightItemByteBuffer, binary.BigEndian, uint8(4))
Should be
binary.Write(c.inFlightItemByteBuffer, binary.BigEndian, uint8(1))
thank you
Allow passing in a custom *Logger
in APNSConfig
so logging can be passed to more than just stdout.
I'm making a beanstlkd worker that listens for HTTP requests to send a notification from an external source.
As it receives these, it adds it as a payload to your package.
I need it to always be running.
I'm looking at your sample code: https://gist.github.com/joekarl/86d9bdb8f9af044710b7
To achieve this, do I just never send a message through the doneWritingChan channel?
Also what do I do if the connection gets closed. How can I automatically open the connection?
Currently non-existent. Just needs interface for socket creation and return types.
Basically because message validation is done behind the channel interface, there's no good way to get back errors if a payload is bad.
Thinking about moving payload validation to an exposed method so that users can pre-validate their messages if they want to.
Will still leave checks in place internally for saneness but will allow preemptive catching of potential errors.
Just a suggestion, but I spent a while debugging an error where I was trying to send payloads that would force an Apple error response, and because I'm lazy I was trying to do this by using invalid tokens like "abcd"
.
What I realised is that, because this is hex-decodable, the library is happy with it, but it causes an non-obvious bug. Given Apple expects tokens to be 32 bytes, sending a message with a token that's any other size will mean all the other fields are out of place. I ended up getting a MISSING_PAYLOAD
for both valid and invalid tokens (due to framing - I was sending batches of notifications) and it took me a while to realise what the problem actually was.
So I was wondering whether it would be appropriate to introduce a token length check in bufferPayload()
that returns an error if the non-decoded token is anything other than 64 bytes (this way we can avoid wasting time decoding it if it's an invalid length). It should go just before this line (
Line 346 in 2076571
When Disconnect() is called, all that happens is the in flight buffer gets locked and then the socket is closed. The problem is if this is used in a multithreaded environment and there are any unsent payloads outside of the inflight buffer after Disconnect is called, the inflight buffer will never be flushed and there's a potential to lose whatever payload was being added as the connection was closed.
Probably just need to add an extra conditional here (https://github.com/joekarl/go-libapns/blob/master/connection.go#L299-L309) so that if the connection closed without an apple error, we return the unsent payload(s).
I'm reading your example code on: https://gist.github.com/joekarl/86d9bdb8f9af044710b7
I can't figure out how to detect the notifications that weren't sent after an error and then to resend them.
Currently the function for creating an APNSConnection
with a custom socket is private (used by the test). This functionality would be useful publicly for sandboxed environments where a different net.Conn
implementation must be used (e.g., App Engine's socket module).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.