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

[FIX] #145 - when using TLS reconnects would fail because of listener leaks (events firing on leaked streams) #147

Merged
merged 1 commit into from May 16, 2017

Conversation

aricart
Copy link
Member

@aricart aricart commented May 15, 2017

[FIX] node client fired error on any protocol error. Some protocol errors such as 'stale connection' should have initiated a reconnect.
[FIX] if a client attempted to publish/subscribe to a subject for which it had no permission, an error was generated. New event ('permission_error') will now be sent to the client.

@Blazedd effectively submitted a similar PR.

@aricart
Copy link
Member Author

aricart commented May 15, 2017

Note that I have included 'authorization timeout' as a non-fatal error. Other clients don't handle this. We can remove this behaviour or enhance other clients to reconnect if a server fails to authorize because of some internal load issue. Not sure if this is the right thing to do.

@coveralls
Copy link

coveralls commented May 15, 2017

Coverage Status

Coverage decreased (-0.4%) to 95.28% when pulling abccfb0 on tls-reconnect-leaks into 25cddf6 on master.

@aricart aricart changed the title [FIX] #45 - when using TLS reconnects would fail because of listener leaks (events firing on leaked streams) [FIX] #145 - when using TLS reconnects would fail because of listener leaks (events firing on leaked streams) May 15, 2017
@derekcollison
Copy link
Member

The server should be expected to disconnect after an authorization timeout. I would cleanup the connection and fire the event callbacks.

@aricart
Copy link
Member Author

aricart commented May 15, 2017

It does disconnect. Now the question is do we fire 'error'. On other clients that is what would happen.

@derekcollison
Copy link
Member

Yes I believe so..

@coveralls
Copy link

coveralls commented May 16, 2017

Coverage Status

Coverage decreased (-0.4%) to 95.28% when pulling 9985164 on tls-reconnect-leaks into 25cddf6 on master.

@coveralls
Copy link

coveralls commented May 16, 2017

Coverage Status

Coverage decreased (-0.4%) to 95.28% when pulling 9985164 on tls-reconnect-leaks into 25cddf6 on master.

@aricart aricart requested a review from kozlovic May 16, 2017 14:56
@aricart
Copy link
Member Author

aricart commented May 16, 2017

Updated so the client disconnects on the authorization timeout error. Added another test without tls which will always get the error from the server.

Copy link
Member

@kozlovic kozlovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM except for 2 minor things.

lib/nats.js Outdated
@@ -91,6 +91,9 @@ var VERSION = '0.7.18',
NATS_PROTOCOL_ERR = 'NATS_PROTOCOL_ERR',
REQ_TIMEOUT = 'REQ_TIMEOUT',
REQ_TIMEOUT_MSG_PREFIX = 'The request timed out for subscription id: ',
STALE_CONNECTION_ERR = "stale connection",
PERMISSIONS_ERR = "permissions violation",
AUTHORIZATION_TIMEOUT_ERR = "authorization timeout",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

test/perms.js Outdated
nsc.stop_server(server);
});

it('foo can subscribe/pub foo', function (done) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would not test the positive cases here, this is a server test, not a client. You want to test a part of the code that handles the failure, so I would keep only negative tests where we try to pub/sub and get an error and check that connection is not closed.

…leaks (events firing on leaked streams)

[FIX] node client fired error on any protocol error. Some protocol errors such as 'stale connection' should have initiated a reconnect.
[FIX] if a client attempted to publish/subscribe to a subject for which it had no permission, an error was generated. New event ('permission_error') will now be sent to the client.

Version Bumps
@coveralls
Copy link

coveralls commented May 16, 2017

Coverage Status

Coverage decreased (-0.4%) to 95.28% when pulling be8fa84 on tls-reconnect-leaks into 25cddf6 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 95.28% when pulling be8fa84 on tls-reconnect-leaks into 25cddf6 on master.

1 similar comment
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.4%) to 95.28% when pulling be8fa84 on tls-reconnect-leaks into 25cddf6 on master.

@kozlovic
Copy link
Member

LGTM

@aricart aricart merged commit 43604b2 into master May 16, 2017
@aricart aricart deleted the tls-reconnect-leaks branch May 16, 2017 17:06
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 this pull request may close these issues.

None yet

4 participants