Closed joffrey-bion closed 5 months ago
STOMP 1.1 is designed to be backwards compatible with STOMP 1.0 while introducing several new features not present in STOMP 1.0:
host
header in CONNECT
/STOMP
frame)STOMP 1.2 is mostly backwards compatible with STOMP 1.1. There are only two incompatible changes:
Apart from these, STOMP 1.2 introduces no new features but focuses on clarifying some areas of the specification such as:
NACK
frames are not supported in 1.0, but there is no harm in trying (maybe some servers support them anyway despite negotiating 1.0?)STOMP
frame is not mentioned in 1.0, but also not mentioned as an addition in 1.1. Also, the lack of CONNECT
in the EBNF grammar of 1.0 doesn't rule out the possibility that STOMP
frames could be supported by some 1.0 servers. Therefore, we shouldn't fail early if the user set connectWithStompCommand=true
(the default is still false
, which is the most compatible option).\n
as line ending as it's compatible with all versions, no need to use \r\n
ourselves, no matter the platform. We also already accept \r\n
in received frames (via readLineStrict()
), and there is no need to eagerly fail on \r\n
if the negotiated version is <= 1.1."1.0"
the default value if no version
header is present in the CONNECTED
framehost
header of the CONNECT
frame is not supported in 1.0, we should avoid sending it in this caseACK
/NACK
frames somehow
Problem / use case
The web socket protocol defines a way to negotiate subprotocols via the
Sec-WebSocket-Protocol
header. STOMP is one such subprotocol, and has several values registered in IANA's WebSocket Subprotocol Name Registry:v10.stomp
,v11.stomp
,v12.stomp
.While sending this header is technically not mandated by the STOMP spec, some servers might decide that they require the header in order to speak the STOMP protocol (which is a valid requirement to set), in which case Krossbow simply cannot communicate with them.
Also, some servers such as ActiveMQ don't actually respect the web socket spec entirely, and may return a protocol in
Sec-WebSocket-Protocol
even though none was sent by the client. This breaks some strict client implementations (such as Darwin'sNSURLSessionWebSocketTask
), which actively check that the negotiated protocol was sent by the client (see https://github.com/joffrey-bion/krossbow/issues/492).Feature (solution)
It would be more correct for the Krossbow client to specify that it wants to speak STOMP v1.2 by sending the
Sec-WebSocket-Protocol=v12.stomp
header.Going further, we could consider sending all 3 header values, and making sure we adjust Krossbow's behaviour based on the version selected by the server. Essentially, we could support older versions of STOMP through this negotiation.
Current alternatives
It is not always possible. In some client implementations like Ktor, we can define a default request with the header, but that's quite a hack. In most other client implementations, we simply can't do anything to make Krossbow send that header.