connect
Connects to the given WebSocket url and to the STOMP session, and returns after receiving the CONNECTED frame.
If login and passcode are provided, they are used to connect at STOMP level (after the web socket connection is established).
If some customStompConnectHeaders are provided, they are included in the CONNECT (or STOMP) frame and might be used by the server for various usages, e.g. Authorization. Note that this frame is a STOMP-level frame, and is sent after the web socket handshake. The customStompConnectHeaders are not sent during the web socket handshake itself. If you need to sent custom headers in the web socket handshake, use the WebSocketClient directly to establish the web socket connection (with custom headers), and then perform the STOMP handshake as a second step over the existing web socket connection using WebSocketConnection.stomp.
The host
header of the CONNECT (or STOMP) frame can be customized via the host parameter. This header was introduced as mandatory since STOMP 1.1 and defaults to the host of the provided URL, or is not send in case version 1.0 of the STOMP protocol was negotiated during the web socket handshake as subprotocol. Some old STOMP servers may refuse connections with a host
header, and not advertise themselves as 1.0 servers during the web socket handshake, in which case you can force it to null to prevent it from being sent.
An additional sessionCoroutineContext can be provided to override the context used for the collection and decoding of the STOMP frames in the created StompSession. By default, the session uses Dispatchers.Default, but it can be overridden here. This is mostly useful to inject a test dispatcher.
Throws
if this method takes longer than the configured timeout (as a whole for both WS connect and STOMP connect)