stompgem / stomp

A ruby gem for sending and receiving messages from a Stomp protocol compliant message queue. Includes: failover logic, ssl support.
http://stomp.github.com
Apache License 2.0
152 stars 80 forks source link

disconnect method fails when using a Hash to connect #19

Closed 2potatocakes closed 13 years ago

2potatocakes commented 13 years ago

Hi guys,

It could be I'm doing something wrong.. just thought I'd run this by you guys though in case I'm not.

I seem to get different behavior when trying to disconnect a stomp connection from ActiveMQ 5.4

When I use Stomp::Connection.new('', '', 'localhost', 61613, false) it seems to work fine, when I use a Hash instead of parameters though, I seem to have trouble disconnecting cleanly and get "Transport failed" errors from ActiveMQ and an error that comes out in my console "receive failed: stream closed"

I put a gist up for you to look at, please let me know if I'm just being stupid and leaving something out of the hash. https://gist.github.com/1205377

morellon commented 13 years ago

Can you test with

Stomp::Connection.new('', '', 'localhost', 61613, true)

and check if it behaves like the hash parameters?

gmallard commented 13 years ago

What version of the gem are you running?

I just tested with your code in the pastie, and get:

[gmallard@tjjackson ~]$ ruby sdisconn.rb 
unsubscribing
disconnected
unsubscribing
disconnected
[gmallard@tjjackson ~]$ 
2potatocakes commented 13 years ago

I switched computers just to make sure it wasn't something local to my machine at work but still get the same result. I tried Stomp::Connection.new('', '', 'localhost', 61613, true) and false and both seem to work fine, no errors. On my home computer I'm now also getting the same as you Guy in my console output and I no longer get the receive failed: stream closeddisconnected output (I'm using a different ruby-debug gem though here and different version of ruby). But either way, the ActiveMQ output still shows the same error that I was getting at work each time I try and disconnect when I've connected using the Hash. INFO | Transport failed: java.net.SocketException: Connection reset

I'm using: Ruby 1.9.2p136 (2010-12-25) [i386-mingw32](Am using Ruby1.8.6 at work) gem -v 1.8.5 stomp 1.1.9 ActiveMQ 5.5

gmallard commented 13 years ago

Primary question: Is this something that is causing pain in a 'production' environment?

You are running Win boxes from what I can tell. The results are definitely OS related. I cannot recreate on any of several Linux machines.

I do not have a Win box, however, when I:

I get somewhat similar results - but not exactly the same.

Example 1 shows:

unsubscribing
disconnected

and in AMQ:

jvm 1    |  INFO | Transport failed: java.io.EOFException

Example 2 shows:

unsubscribing
disconnectedreceive failed: closed stream

and nothing in the AMQ log.

My OSX box gives yet another subtle variation of the Windows behavior. Same results as Windows in the terminal output, but nothing in AMQ logs for either example.

2potatocakes commented 13 years ago

Yeah, sorry, should've said I'm on windows at the moment. Tracked it down to the @read_semaphore mutex thread still attempting to do stuff when the close socket command comes in which throws an IOError, tried a few different things to fix it. Think I've found a fix.. I'll put in a pull request now. Let me know if it's ok

2potatocakes commented 13 years ago

Sorry to have caused u any grief with this guy. I am using this gem in a production environment but this error isn't a showstopper. I was just wondering what was causing it and was worried i was doing something wrong.

gmallard commented 13 years ago

np. I don't think you are doing anything 'wrong'.

To me it is actually a surprise that I get zero error messages under Linux.

Some kind of error message would seem natural, and I am surprised when I do not get one.