Skip to content

Instantly share code, notes, and snippets.

@2potatocakes
Created September 9, 2011 02:44
Show Gist options
  • Save 2potatocakes/1205377 to your computer and use it in GitHub Desktop.
Save 2potatocakes/1205377 to your computer and use it in GitHub Desktop.
disconnect results in "Transport failed" error in ActiveMQ when using hashed login
####Example 1 - Connecting to stomp without using a Hash seems to work correctly
require 'stomp'
@queue_name = "/queue/testing_kill_thread"
@subscription_headers = {:ack => 'client'}
thread = Thread.new do
@stomp = Stomp::Connection.new('', '', 'localhost', 61613, false)
@stomp.subscribe(@queue_name, @subscription_headers)
msg = @stomp.receive
end
sleep(2)
puts "unsubscribing"
@stomp.unsubscribe(@queue_name, @subscription_headers)
@stomp.disconnect
puts "disconnected"
#==> unsubscribing
#==> disconnected
## ActiveMQ - No errors - All seems to be working correctly
####Example 2 - This way doesn't seem to disconnect properly when using a Hash to connect
require 'stomp'
@stomp_connection_hash = {
:hosts => [
{:login => '',
:passcode => '',
:host => 'localhost',
:port => 61613,
:ssl => false}
]
}
@queue_name = "/queue/testing_kill_thread"
@subscription_headers = {:ack => 'client'}
thread = Thread.new do
@stomp = Stomp::Connection.new(@stomp_connection_hash)
@stomp.subscribe(@queue_name, @subscription_headers)
msg = @stomp.receive
end
sleep(2)
puts "unsubscribing"
@stomp.unsubscribe(@queue_name, @subscription_headers)
@stomp.disconnect #The error below is coming when disconnect is called here
puts "disconnected"
#==> unsubscribing
#==> receive failed: stream closeddisconnected
## ActiveMQ - Error
# INFO | Transport failed: java.net.SocketException: Connection reset
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment