stomp-php / stomp-php

Stomp PHP Client
https://github.com/stomp-php/stomp-php/wiki
Apache License 2.0
125 stars 57 forks source link

Sends multiple CONNECT frames then crashes if 1.2 CONNECTED doesn't include optional session and server headers #179

Open EvelynSubarrow opened 11 months ago

EvelynSubarrow commented 11 months ago

If selenetherium doesn't supply session and server headers in its CONNECTED frame:

CONNECT
accept-version:1.0,1.1,1.2
host:192.168.0.59
heart-beat:0,0

^ CONNECTED
version:1.2

^ CONNECT
accept-version:1.0,1.1,1.2
host:192.168.0.59
heart-beat:0,0

^ CONNECTED
version:1.2

^ SUBSCRIBE
destination:test_queue
ack:client
id:6250520166077902233
selector:test_queue_placeholder
activemq.prefetchSize:1
receipt:71806d91e413075ecdc5c1b7debb029b
[...]

It emits a few more CONNECT frames interspersed with normal operation before eventually crashing with the error message Unexpected response received. Expected a "CONNECTED" Frame to determine Version. Got a "Message" Frame

If session and server headers are supplied, this behaviour isn't exhibited, and it works fine.

CONNECT
accept-version:1.0,1.1,1.2
host:192.168.0.59
heart-beat:0,0

^ CONNECTED
version:1.2
session:placeholder
server:Selenetherium/0.0.0

^ SUBSCRIBE
destination:test_queue
ack:client
id:4903425750406440245
selector:test_queue_placeholder
receipt:f8525dfa0c1d83b28066280b483a4449
[...]

session is ambiguously defined in 1.0, it could be interpreted as being required, but in all future versions, all headers except version are optional in CONNECTED.

whikloj commented 10 months ago

Hi @EvelynSubarrow,

I don't know what selenetherium is, is that a client or server built using stomp-php? Just trying to understand the issue here and on what side stomp-php is on.

EvelynSubarrow commented 10 months ago

Hi @whikloj, not the clearest explanation on my part, selenetherium is a server. In the logs, all client frames came from stomp-php, and all server frames from selenetherium. I wrote Selenetherium as a client tester to help me build a list of compatible STOMP clients on the NROD wiki.

To describe the bug here more (hopefully) more exactly, stomp-php expects a CONNECTED frame from a broker to have server and session headers under STOMP 1.1, even though only version is actually required.

https://wiki.openraildata.com/index.php?title=List_of_STOMP_Client_Libraries https://codeberg.org/Subarrow/Selenetherium

whikloj commented 10 months ago

This may be helpful as there are parts of this codebase that are less clear to me. So I'm compiling selenetherium, but as I'm not an Erlang developer can you tell me how to get it running and if it is possible to limit the tests run to specific ones?