jackytu / nats Goto Github PK
View Code? Open in Web Editor NEWThis project forked from nats-io/nats.rb
A lightweight cloud messaging system.
Home Page: http://github.com/derekcollison/nats
License: MIT License
This project forked from nats-io/nats.rb
A lightweight cloud messaging system.
Home Page: http://github.com/derekcollison/nats
License: MIT License
HI, Derek:
In our recent practice, we found that if the application not exit when nats-client auth failed (e.g cloudfounry1.0/router ), the client won't exit until eventmachine raise ‘ran out of timers’ exception (after 100000 reconnect attempt), it can be reproduced as the spec test later.
There are several points about this:
And I think there are some ways to solve this:
1. Only add ping timer after auth is OK;
2. Not setting reconnec_attempt to 0, if the server to connect is just the same server connected before;
Spec test (auth_spec.rb):
it 'should giveup reconnect to an authorized server without proper credentials after max attempt' do
EM.set_max_timers(100)
expect do
EM.run do
NATS.on_error do |e|
if e.kind_of? NATS::ConnectError
EM.stop
else
p "NATS problem, #{e}"
end
end
NATS.start(:uri => TEST_AUTH_SERVER_NO_CRED, :max_reconnect_attempts => 2) {
EM.add_timer(10){
EM.stop
}
}
end
end.to_not raise_error
end
And the test would failed as following:
authorization should giveup reconnect to an authorized server without proper credentials after max attempt
Failure/Error: expect do
expected no Exception, got #<RuntimeError: ran out of timers; use #set_max_timers to increase limit> with backtrace:
# ./lib/nats/client.rb:615:in `connection_completed'
# ./spec/auth_spec.rb:40:in `block (3 levels) in <top (required)>'
# ./spec/auth_spec.rb:39:in `block (2 levels) in <top (required)>'
# ./spec/auth_spec.rb:39:in `block (2 levels) in <top (required)>'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.