Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce the access token refresh interval rate. Based on https://suppo…
- Loading branch information
166aaa5
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.
Why is it that 10 (seconds) is subtracted from $this->tokenExpires ?
Exact gives a value of 600 (seconds / 10min), why subtract 10 seconds from that? Wouldn't this result in requesting a new token too early?
166aaa5
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.
@TWSnijders I don't know for this specific case, but we do that in a lot of our clients to prevent calls that will fail. So we will try to refresh an expiring token a bit sooner, and with rate limits we will hold off a bit earlier. We think that is being a good web citizen. If you know that the token will almost expire, it is better to refresh it already then to wait for a 400 response.
It could also be 2 or 5 seconds, but in this case it is 10 seconds. The specific implementation does not matter that much.
166aaa5
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.
@casperbakker Problem we have is that we get a message that the token is not expired yet, so we are not getting a new token.
If that 10 seconds was not there, I would expect we would not get that error anymore.
166aaa5
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.
That sounds like a bad implementation on Exact's side. Time can be out of sync a little bit. So than you really need to wait for it to expire, and only then refresh it.
I don't know much about this library, but I don't think this is the problem as this code is used in a lot of (big) projects, and this code is there for years.
166aaa5
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.
It being used by many (big) companies and it being there for a long time, does not make it right.
This library makes a connection with the connect() function which calls checkOrAcquireAccessToken() which in turn checks tokenHasExpired().
Because of that -10 seconds, the code tells us the token is not expired yet (but has) and we then try to make a new connection with that (expired) token, which then gives us an error (from Exact) that the token is not expired yet.
So if all these checks are already done, I don't see a reason as to why one would subtract that 10 seconds from the token expire time, when this is checked before setting up the connection.
166aaa5
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.
What I meant is that I doubt this 10 seconds offset is the reason for your error. As we would have seen this error many times before and then it would be fixed.
But as I said, I am not very into this library, so I cannot look into this further. You can try create an issue and see if someone else knows what the problem is.