I am connecting to an websocket endpoint using stompjs. One of the parameters is connectHeaders
headers but it does not use these headers in the http request headers? Where does it use these headers?
export const stompClient = new Client({
brokerURL: "ws://localhost:8080/gs-guide-websocket",
connectHeaders: {
Ad: "asjfasfjldskfjsklfajsdklfasdf",
login: "user",
passcode: "password"
},
debug: function (str) {
console.log(str);
},
});
Those headers are used in the Stomp frame, specifically the CONNECT
frame. Stomp frames are modeled on HTTP frames, but they are not synonymous. Stomp headers are distinct from HTTP headers as Stomp is not tied to HTTP. As noted in the Stomp 1.2 specification for the CONNECT
frame:
STOMP 1.2 clients MUST set the following headers:
accept-version
: The versions of the STOMP protocol the client supports. See Protocol Negotiation for more details.host
: The name of a virtual host that the client wishes to connect to. It is recommended clients set this to the host name that the socket was established against, or to any name of their choosing. If this header does not match a known virtual host, servers supporting virtual hosting MAY select a default virtual host or reject the connection.STOMP 1.2 clients MAY set the following headers:
login
: The user identifier used to authenticate against a secured STOMP server.passcode
: The password used to authenticate against a secured STOMP server.heart-beat
: The Heart-beating settings.