Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

websockets protocol #3832

Open
Mahdi-Ba opened this issue Jul 7, 2024 · 1 comment
Open

websockets protocol #3832

Mahdi-Ba opened this issue Jul 7, 2024 · 1 comment
Assignees
Labels
awaiting user waiting for user to respond bug

Comments

@Mahdi-Ba
Copy link

Mahdi-Ba commented Jul 7, 2024

Brief summary

in websockets protocol

//below code doesn't work and didn't send to the server 

socket.send(JSON.stringify(messageObject));

//But below is working 

   socket.setInterval(function timeout() {
                socket.send(JSON.stringify(messageObject));
                console.log('message sent');
            }, 1000);

k6 version

v0.52.0

OS

macOS M1 14.3.1 (23D60) Sonoma

Docker version and image (if applicable)

No response

Steps to reproduce the problem

I submit message but any message received in server in websockets protocol

Expected behaviour

I Expected without interval I receive message too

Actual behaviour

in websockets protocol with interval, I receive But in normal behavior doesn't work

@mstoykov
Copy link
Collaborator

mstoykov commented Jul 8, 2024

Hi @Mahdi-Ba, can you provide a full example, as I can't reproduce the problem you are having with the following script

import ws from 'k6/ws';

export default function() {
	const url = 'wss://echo.websocket.org';
	let res = ws.connect(url, function(socket) {
		socket.on('error', console.log)
		socket.on('open', function open() {
			console.log('connected');
			socket.send("hello");
			socket.setTimeout(function timeout() {
				socket.close()
			}, 1000);
			socket.setInterval(function timeout() {
				socket.send("other mesasage");
			}, 500);


		});

		socket.on('message', (msg) => console.log('message!', msg));
	});
	if (res.status != 101) {
		console.log(JSON.stringify(res));
	}
}

@mstoykov mstoykov added awaiting user waiting for user to respond and removed triage labels Jul 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting user waiting for user to respond bug
Projects
None yet
Development

No branches or pull requests

2 participants