-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Possible fix for #14 Socket connection drops next notification if invalid notification is sent #29
base: master
Are you sure you want to change the base?
Conversation
@@ -32,6 +32,14 @@ def connect | |||
ssl.connect unless ssl.connected? | |||
end | |||
|
|||
def select timeout |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think def select(timeout)
is much more readable.
…payload is mor than 256 bytes.
errors = [] | ||
read, write, error = @connection.select(timeout) | ||
if !error.nil? && !error.first.nil? | ||
Rails.logger.error "IO.select has reported an unexpected error while sending notifications." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This couples us directly to Rails
, which we can't do.
We are unlikely to accept any pull requests without accompanying specs. Also, please try to adhere to the code style of this project - that is, we don't use the Seattle-style method defs: # prefer
def method_name(arg = default)
#...
end
# instead of
def method_name arg = default
#...
end |
I see a bunch of style issues, between the method definitions and use of Rails logger. |
Hi @kbrock, Would you care to take a crack at adding some specs or addressing some of the issues we've brought up? |
FWIW, I'm using @Aleph7's read_reply patch to handle issue #14 . I have this something like this (I've removed a bunch of guards and logging). The basic idea is to look for the error response packet and re-send everything in the batch after the notification that caused the error. YMMV, but I think it illustrates that this could possibly be handled in client code
|
for @johnnaegle code If I had a bad token in to_send, it only made it 2 or 3 notifications past until it blew up. If I went further than that, I was not able to determine that there was even an error, and would not know which notifications had been sent or not. It may be the issue with the branch resetting connections on error |
Hi, I got the same problem as described in issue #14. Later on I discovered than "invalid" device tokens which trigger the problem came from Debug versions of my app. Basically Apple drops connection and does not send anything as soon as it sees token from sandbox environment send to production one. Once I removed sandbox tokens my pushes sent fine.
But this is only part of the picture. I dig a bit deeper and implemented simple error checking as described in apple docs. You can see this code in the pull request. I used IO.select trick from "Lead Zeppeling" to get error messages. And weird thing happened. Once I read errors I see that Apple correctly reports sandbox tokens as being invalid (error code 8). But Apple reports it only once! Next pushes with same tokens (including invalid once) work without connection drops and without any errors from Apple side. I do not know who to blame this for. Maybe IO.select did the trick, maybe reading error information from socket, maybe anything else...
Anyway this pull request has the code I created to read errors. And using it I was able to fix the problem.
My sending code looks like this