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

unexpected response from server: "!!! -ERR 'Authentication Timeout'␍␊" #205

Closed
nidi3 opened this issue Jul 24, 2023 · 6 comments · Fixed by nats-io/nats.deno#562
Closed

Comments

@nidi3
Copy link

nidi3 commented Jul 24, 2023

From time to time we get an "unexpected response from server" Error and on the console there's the message "!!! -ERR 'Authentication Timeout'"

  • What does this mean?
  • How should this be handled?
  • The application has no access to the message, so we currently cannot implement a special action depending on the message.

Thanks

@aricart
Copy link
Member

aricart commented Jul 26, 2023

@nidi3 That means that the client was presented with a connect, but didn't authenticated quickly enough

there could be several reasons for this:

  • if you changed these values on the server, and there was some latency (note that if the tls handshake doesn't complete within this time but that is only applicable to clients that upgrade the connection - not the case if you are using nats.ws)
  • if you are using an authenticator and configured it using a function that is taking too long to return the credentials.

If the client fails to connect, and you have reconnect enabled, the client should just attempt to reconnect

Can you show your client config options and also verify that the server doesn't have a timeout directive for authorization
The config could have something like this:

authorization: {
    timeout: 3

@nidi3
Copy link
Author

nidi3 commented Jul 27, 2023

Hi @aricart

Thanks for the quick answer!

Indeed, we have an authorization timeout set. We'll try to set it higher.

If the client fails to connect, and you have reconnect enabled, the client should just attempt to reconnect

Not sure about this part. We have reconnect enabled in the ConnectionOptions, so nats.ws should attempt to reconnect automatically? It seems not to.
Or should the application repeat the call?

There are two possible errors:

  • error.message == "'Authentication Timeout'"
  • error.message == "unexpected response from server" with more details only logged on the console in debug mode.

The first case we can handle in the application, for the second case we don't know what the unexpected response was.

@aricart
Copy link
Member

aricart commented Jul 27, 2023

@nidi3, I am hoping on your side, you are NOT using an authenticator function that is async.
With that said, if the client is not configured with the option waitOnFirstConnect: true, it will attempt to reconnect only a few times, after that the connection will close. Is that your experience?

@aricart
Copy link
Member

aricart commented Jul 27, 2023

@nidi3 really want to know what your connection options are for the client, and the timeout for the server.

@aricart
Copy link
Member

aricart commented Aug 1, 2023

@nidi3 thanks for finding this, fix should be in the next release

@aricart aricart closed this as completed Aug 1, 2023
@nidi3
Copy link
Author

nidi3 commented Aug 2, 2023

Hi @aricart
Thanks for the fix, looks interesting.
Indeed, we have waitOnFirstConnect: false, we'll try to see if setting it to true helps.

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

Successfully merging a pull request may close this issue.

2 participants