iande / onstomp

A STOMP messaging client library for Ruby
http://mathish.com/projects/onstomp.html
Other
23 stars 11 forks source link

Fixes headers when there is no login/passcode #25

Closed skanct closed 9 years ago

skanct commented 9 years ago

In the current implementation, if the user does not define a login and passcode, then the library sets their values to '' and the headers that are sent to the STOMP server are the following:

CONNECT
accept-version:1.0,1.1
host:stomp-server.example.com
heart-beat:0,0
login:
passcode:

When this is tested against ActiveMQ (version 5.8.0), the connection fails with the following error:

ERROR
content-type:text/plain
message:User name [] or password is invalid.

According to the STOMP protocol specification, the clients MAY set the login and passcode headers. It seems that when the user does not define a login and passcode, then the CONNECT frame must not include these headers.

This commit changes the existing behaviour and when the user does not define a login and a passcode, then the library does not include these headers in the CONNECT frame.

iande commented 9 years ago

This is definitely an issue, and one that has been around for a surprisingly long time. However, fixing it in the Client isn't the right place to tackle it, but the connection code is so convoluted that I don't blame you for applying a fix there.

See issue #28 for more on this issue and its resolution.