Coder Social home page Coder Social logo

Comments (11)

sahilm avatar sahilm commented on July 28, 2024

Periodically publishing to a hearbeat topic seems to trigger the reconnect logic. Tested with RabbitMQ 2.8.6.1

require 'bundler/setup'
require 'stomp'
require 'json'
require 'pp'

hash = { :hosts => 
  [
   { :login => "guest",
     :passcode => "guest",
     :host => 'localhost', 
     :port => 61613,
   }
  ]
}

client = Stomp::Client.new(hash)

client.subscribe("/queue/foo")   do |message|
  if message.headers["content-type"] =~ /json/
    pp JSON.parse(message.body)
  else
    pp message.body
  end
end

Kernel.trap(:INT) {
  client.close
  puts "Recieved term, stopping..."
  exit 0
}

loop do
  sleep 1
  begin
    client.publish("/topic/heartbeat","beat")
  rescue Stomp::Error::NoCurrentConnection => e
    puts "Retry in 1s"
    sleep 1
    retry
  end
end

from stomp.

gmallard avatar gmallard commented on July 28, 2024

Hi - I could not recreate this here with a quickly setup test (using AMQ) on Ubuntu, however will continue to experiment a bit.

What gem version are you running?

Why does your example require 'bundler/setup? It seems unused.

What Ruby version? (Should not matter, but ....).

With AMQ are you using 'stomp://' or 'stomp+nio://'? AMQ 5.7.0 has some ragged edges when using nio.

Are your brokers on the same machine as the client?

If you could enable a call back logger (see the examples) for one of these tests, and pastebin the output that might be helpful.

Thanks, Guy

from stomp.

gmallard avatar gmallard commented on July 28, 2024

FYI - I have not been able to recreate this in a variety of tests and environments.

Servers used: AMQ 5.7.0 and RabbitMQ 2.8.4. Both servers on Linux (Ubuntu). I did not test against Apollo, but am confident the results would be the same.

Client environments used: Ubuntu 11.10, Win 7, OSX 10.8.0.

In all these tests reconnecting at least 3 times succeeds.

One point to note: give the 'subscribe' parameters you use above, even if you do reconnect, it is likely that there will be nothing to receive from /queue/foo. You need something other than :ack => "auto" to prevent that.

from stomp.

sahilm avatar sahilm commented on July 28, 2024

Thank you very much, Guy. I've been a tied up since the past few days. I'll be sure to follow up with more comprehensive test results and data ASAP.

from stomp.

gmallard avatar gmallard commented on July 28, 2024

Any updates on this? Just curious ......

Thanks, Guy

from stomp.

gmallard avatar gmallard commented on July 28, 2024

This issue report is ancient. I am going to close this, with no resolution.

Please re-open this issue including code that can reproduce the problem when you have developed that code.

from stomp.

pic avatar pic commented on July 28, 2024

I'm experiencing the same with AMQ 5.5.1 . Gem version is 1.2.8
I can constantly reproduce the problem with these steps:

  • start AMQ
  • start my consumer, it connects immetiately, all fine
  • stop AMQ, consumer starts to try to reconnects
  • start AMQ again, consumer reconnect, all fine
  • stop AMQ, consumer dies, exception is in lib/client/utils.rb , line 100, message is nil

I can provide more info, I can test with AMQ 5.7.0 too, please let me know

from stomp.

pic avatar pic commented on July 28, 2024

same behaviour with AMQ 5.7.0

from stomp.

gmallard avatar gmallard commented on July 28, 2024

Thanks. With your description, this can actually be recreated. Reopened.

from stomp.

pic avatar pic commented on July 28, 2024

thanks to you, tell me if you need more info

from stomp.

gmallard avatar gmallard commented on July 28, 2024

Thanks for the hint about utils.rb, line 100. That was being masked in previous attempts to recreate this.

Closed: 3198504

from stomp.

Related Issues (20)

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.