Skip to content
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

Status: 500 Response Reason:InternalServerError #463

Closed
AndySoHotRightNow opened this issue Nov 5, 2016 · 10 comments
Closed

Status: 500 Response Reason:InternalServerError #463

AndySoHotRightNow opened this issue Nov 5, 2016 · 10 comments

Comments

@AndySoHotRightNow
Copy link

AndySoHotRightNow commented Nov 5, 2016

First of all, well done to argon and the new administrators.

Secondly, I have been using this repo for a while without problems.

Recently, I switched to the new Provider Authentication Tokens and everything seemed to be working smoothly.

Until I realized that at some point all my notifications stop working and return a 'Status: 500', and response with 'Reason: InternalServerError'. I did a little search and came across this very recent question on StackOverflow which describes the same problem:

http://stackoverflow.com/questions/40429009/why-apple-push-notification-service-sometimes-gives-me-error-500?newreg=986d81b4ce884d1dbf375074413286ae

If I restart the server everything seems to go back to normal for an indefinite amount of time (usually a couple of hours). Very few diluted notifications are sent between each restart.

I am using version 2.1.1.

@oliversalzburg
Copy link

Given that the response indicates a server-side error, have you contacted Apple Developer Support about this? Maybe they can provide more details.

@ffager83
Copy link

ffager83 commented Nov 6, 2016

We're seeing exactly this error as well.
Last week we updated to token based APN auth (certificates was about to expire) and node-apn from version 1.7.5 to 2.1.1, and started seeing this issue pretty much directly after that.

Some notifications get successfully pushed, but on most of them we get the "Error 500 - InternalServerError" response.

Have they changed (made more strict?!) the notification payload format? I mean, there shouldn't be anything "illegal" in the payload, but just thought I would ask.

Also other error we get, but not as often as the InternalServerError:

  • VError: stream ended unexpectedly
  • [VError: apn write failed: connection error: PROTOCOL_ERROR]
  • [VError: apn write failed: GOAWAY: REFUSED_STREAM Maximum active streams violated for this endpoint.]

We're using node 4.5.0 LTS + node-apn 2.1.1

I wish I could help more debugging this.. :/
Thank you in advance

@AndySoHotRightNow
Copy link
Author

AndySoHotRightNow commented Nov 7, 2016

I am not an expert in APN and just making a wild guess. I don't see this domino effect happening for other errors (such as 410 - unregistered) therefore, could it be that for some reason, when this specific error is fired the connection is closed by Apple and not re-opened client-side?

I am saying this under two assumptions:

  1. That Apple will close a connection when an error is encountered (even if not 500).
  2. That node-apn provides a persistent connection with Apple's server even in spite of errors which may close a connection. (Please correct me if I'm wrong, I'm inferring this from argon's answer to this question here).

Also, I personally don't think that Provider Authentication Tokens could be part of the issue as this is merely an authentication system.

I am inclined to believe that this may be a client-side issue as a mere server restart solves the problem, which I think should rule out any penalty/ban from Apple at a provider level.

😢

@sambegin
Copy link

sambegin commented Nov 7, 2016

This is clearly the same problem I've encountered... Opened issue #461 a weak ago and did not find any clue on what's happening.

I've put more log to show how we've progressed before having a Internal server error : 500

@AndySoHotRightNow
Copy link
Author

AndySoHotRightNow commented Nov 7, 2016

@sambegin I've read through your issue and while I am not observing the other "weird" errors at the moment I concur on the 500 error.
@oliversalzburg Thanks for the advice however I'm reluctant to contact Apple Developer Support at the moment because:

  1. I do not have extensive knowledge of APN.
  2. If I mention the fact that I am getting a domino effect with error 500 the question would arise as to whether I am re-opening the connection correctly. As I mentioned earlier I'm basing this on the unconfirmed assumption that

Apple will close a connection when an error is encountered

If that's the case I first of all need to be entirely sure that the re-connection is being performed flawlessly client-side by node-apn.

On a side note, as a work-around to this issue I am resetting my provider variable as soon as I spot the first error 500:

provider = new apn.Provider({  
    token: {
        key: // Path to the key.p8 file.
        keyId: // Key ID of the key.p8 file (available at https://developer.apple.com/account/ios/certificate/key).
        teamId: // Team ID of your Apple Developer Account (available at https://developer.apple.com/account/#/membership/).
    }
});

And that fixes it for all the forthcoming notifications until the next errored-one but isn't this quite hacky (aside from the fact that the errored-notification is skipped)?

@quixoticaxis
Copy link

quixoticaxis commented Nov 7, 2016

I'm in the same boat: a few errors of "write failed" type followed by a bunch of "InternalServerError"s. I guess that node-apn should probably re-open connection on "InternalServerError" because otherwise not only the current message gets lost, but also the next message (it is lost due to write errors while trying to utilize dead connection).

@alappe
Copy link

alappe commented Nov 7, 2016

Yes, we experience the same issues, 500s and timeouts like this:

{
  "jse_shortmsg":"apn write failed",
  "jse_cause":{
    "code":"ETIMEDOUT",
    "errno":"ETIMEDOUT",
    "syscall":"read"
  },
  "jse_info":{},
  "message":"apn write failed: read ETIMEDOUT"
}

Restarting the service (and thus the connection) fixed it for a while as reported above… Why keep the connection at all, I wonder, since it's http/2, isn't it?

@harshpatel19
Copy link

Facing same issue. APNS abruptly starts sending InternalServerError, after restarting the service, it starts working normally.

@sambegin
Copy link

sambegin commented Nov 9, 2016

Do we know more about potential fix (checking health connection with APNs) talked in #449 ?

Seems like a good start to resolve our problems.

@florianreinhart
Copy link
Member

Closing as duplicate of #449.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants