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

Need friendly wrong-service message #28

Closed MaartenG closed 12 years ago

MaartenG commented 12 years ago

If (like me) you're new to ActiveMQ and Stomp, and don't actually have Stomp configured, and try to connect to an ActiveMQ port, the error message is totally unrelated to the actual issue.

irb(main):009:0> client = Stomp::Client.new "stomp://localhost:8161" TypeError: can't convert nil into String

Instead, the error returned should probably be something like "This is not a Stomp server".

gmallard commented 12 years ago

We will at least raise a Stomp error type when this happens with a hopefully more clear message for new Stomp::Client instances. After looking at this code, the actual message should probably be something like:

Connected, malformed STOMP frame received on connect, is this really a STOMP server?

And the message is presented via a Stomp::Error exception. The message should be more clear as to the real problem. The exception will probably not be more friendly.

Suggestions about the actual message are welcome.

There is an allied discrepancy that should probably be fixed in conjunction with this.

Consider the low level Stomp::Connection interface (as opposed to Stomp::Client).

If a STOMP server is listening on port 61613, and a Web Server is listening on port 80, and AMQ native is listening on port 8161, and nothing is listening on port 12345, then any of the following calls will silently and erroneously succeed:

c = Stomp::Connection.new "stomp://localhost:12345"
c = Stomp::Connection.new "stomp://localhost:80"
c = Stomp::Connection.new "stomp://localhost:8161"

In each case the actual connection host is "localhost", and the port connected to is 61613. The passed parameter is interpreted as the login ID.

MaartenG: Thanks for this report. Feel free to fix this, with some tests, and send a pull request :-)

Thiago - I hope you see this. What are your thoughts?

gmallard commented 12 years ago

Closing, fixed with commit 7f83c13f57702d143d4cc8673f7aee1e766e5d41