Websocket connection response code 403

Hello there,

I’ve been trying to connect my custom nodejs backend to videobridge via websockets (bridgeChannel functionality). This way nodejs backend would present one of the conference participants, and would recieve messages that go through videobridge (we are sending custom, not jitsi related, messages through bridgechannel).

Backend is already connected to prosody via xmpp and it is successfully receiving all xmpp messages. I have also figured out that one of the xmpp messages is ‘session-initiate’ message which contains websocket url. I have extracted that url and websocket connection implementation is from that point pretty straightforward.
Now, the problem is that most of the time when backend tries to connect using websocket url, response code 403 is returned.
But worst thing is that, weirdly, when I am in debug mode and stop code execution after extracting websocket url from ‘session-initiate’, and before websocket connection implementation, and wait for approx. one minute, and then continue execution, websocket connection is successful.
All of this leads me to conclusion that something needs to happen before I can establish websocket connection, but I am not sure what.

Thanks in advance