Giter Site home page Giter Site logo

nats's People

Contributors

achied avatar anderscarling avatar bleything avatar danp avatar derekcollison avatar kkas avatar nomoto-1 avatar pietern avatar stefanschneider avatar theganyo avatar tsujimotohiroaki avatar

Watchers

 avatar  avatar  avatar

nats's Issues

NATS-Client not stop reconnecting until ran out of timers if auth failed

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:
  • The client add ping timer right after connection completed;
  • When client connect to the same server, the reconnect_attempt set to 0;
  • When server close connection due to auth fail, the server always be true when can_reuse_server? , since the reconnect_attemp kept being 0 all the time, never reach to the max_reconnect_attempt;
  • And client kept adding ping timer after each reconnection completed;
  • The infinity loop finally exit after 100000 timer limit of eventmachine;

natsfail

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)>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.