Experimental K6 websockets doesn't receive response but built-in does

I have a websocket server and I’m able to use it with built-in K6 websockets to send and receive with BiDi stream without a problem. I wanted to use the experimental websockets because I need the async features. My goal is to send a message from websocket connection A to connection B. with A and B connections running in the same test. This I cannot accomplish with built-in websockets because they are blocking

When using the experimental websockets, I receive nothing but empty object. Although the server do send the response. I don’t received any errors as well and I cannot figure out what is the problem. I tried my experimental websocket implementation with another server and it seems to be working.

This is the message I receive in the response

{"type":"message","target":{"url":"ws://localhost:8080/BiDiEnvelopeChannel/bidicommunication","readyState":1,"bufferedAmount":0,"binaryType":"ArrayBuffer"},"timestamp":1699224191466.812,"data":{},"origin":"ws://localhost:8080/BiDiEnvelopeChannel/bidicommunication"} 

As you see, the data attribute is empty but I should receive the response sent by the server here
Are there any ideas how can I debug this or what possibly could be the problem?

Hi @shoukryelfahl,

Having taken a look at both code bases I see no reason why one will act differently - they do more or less exactly the same thing and use the same underlying library.

Unfortunately without a reproduction I don’t think I can do much more. Can you please try to build a toy project that exhibits the same problem and provide it, so we can try to figure out what is going wrong. If you can reproduce it with another public ws server that might be okay as well.

Any other information you can provide is also going to be helpful such as what the data is - was it a binary message or not; Redacted script; maybe something about the server.

You might also want to open an issue on the xk6-websockets project with the above info as this truly seems like a bug.

Thanks for reporting this and hopefully we will get to the bottom of it.

2 Likes

Thanks @mstoykov
I managed to get it to work. It turns out that when data is binary, it is logged as empty object {}. I was first trying to deserialize the entire payload which was giving me also empty object not error as it should which led to the confusing situation.
Also for some reason, the response from a sample server is returned directly from the payload but the response from my server is returned in the data attribute which was quite confusing. I still need to investigate the difference because in the blocking version of K6 websockets, it was returned directly in the payload

1 Like

I am Glad you fixed it, but I am not certain I understand all the things you mentioned and if I did some of them sound like bugs. So if you can expand on them that will be great :slight_smile:

1 Like