walterwanderley / xk6-stomp

A STOMP protocol client library for k6
Apache License 2.0
5 stars 8 forks source link

Cannot add subscribe headers on client.subscribe? #7

Closed filip8703 closed 1 year ago

filip8703 commented 1 year ago

Hi,

I cannot figure out from the examples if it is possible to add headers on client.subscribe(). I have the following code;

    // Connect to STOMP over WS
    const client = stomp.connect({
        protocol: 'wss',
        addr: 'localhost:443',
        path: '/ws',
        timeout: '10s',
        heartbeat: {
            incoming: '30s',
            outgoing: '30s',
        },
        message_send_timeout: '5s',
        receipt_timeout: '10s',
        verbose: true
    });

    const subscribeOpts = {
        ack: 'auto', // client-individual or auto (default)
    }

    // subscribe to receive messages from 'my/destination' with the client ack mode
    const subscription = client.subscribe('/user/notify/orderReservation', subscribeOpts); 

I have tried to add header: { id: idToSubscribeTo } in the subscibeOpts object but that won't work. Is it supported in the library to add headers to the subscribe function?

I have verified that it is connecting to my websocket and subscribes to /user/notify/orderReservation that i have set up but it doesn't append the headers.

Thanks in advance!

walterwanderley commented 1 year ago

Try to use headers (plural):


const subscribeOpts = {
        ack: 'auto', // client-individual or auto (default)
        headers: { id:  idToSubscribeTo }
}
filip8703 commented 1 year ago

@walterwanderley Thanks alot! Just missed the plural.. sorry for disturbing :)