Comments (2)
I got the same issue and i am very appreciate if anyone knows how to work around it.
from artillery-core.
For anyone who got into the same issue, I kinda found a way to work around this problem by making use of JavaScript.
{
"config": {
"target": "http://localhost:8000",
"phases": [
{
"duration": 1,
"arrivalRate": 1
}
],
"processor": "./custom_processor_metric.js",
"variables": {
"channelId": "1f49b260-94eb-41e2-8f9f-fca20ba9fc96",
"channelToken": "ad09a6b1-19ea-47a1-9b8d-b2c0f42f0a98",
"recipientId": "ad09a6b1-19ea-47a1-9b8d-b2c0f42f0a98",
"senderId": ""
},
"socketio": {
"transports": [
"websocket"
]
}
},
"scenarios": [
{
"name": "Scenario 1",
"engine": "socketio",
"flow": [
{
"function": "initConversation"
},
{
"function": "sendMessage"
},
{
"function": "sendMessage"
},
{
"function": "sendMessage"
}
]
},
{
"name": "Scenario 2",
"engine": "socketio",
"flow": [
{
"function": "initConversation"
},
{
"function": "sendMessage"
}
]
}
]
}
Given the script above, I used JS function instead of directly emitting the message to serve. With this approach, you have to manually verify the response yourself.
module.exports = {
initConversation: initConversation,
sendMessage: sendMessage
};
const artillery = require('artillery-core');
function initConversation(context, events, done) {
events.emit("request");
let startedAt = process.hrtime();
context.sockets["/"].emit("message",
{
"action": "START_NEW_CONVERSATION", "dataType": "UNK", "data": {}, "conversationInfo": { "channelId": context.vars.channelId, "channelToken": context.vars.channelToken, "recipientId": context.vars.recipientId, "chatId": null, "senderId": null }
});
return processSender(context, events, done, startedAt);
}
function processSender(context, events, done, startedAt) {
context.sockets["/"].on("message", function (res) {
try {
context.vars.senderId = res.conversationInfo.senderId;
} catch (error) { // do something
}
if (context.vars.senderId) {
markEndTime(events, context, startedAt);
context.sockets["/"].off("message");
return done();
}
});
}
function sendMessage(context, events, done) {
events.emit("request");
const startedAt = process.hrtime();
context.sockets["/"].emit("message",
{
"action": "UNK", "dataType": "TEXT", "data": "Hello from JS", "conversationInfo": { "channelId": context.vars.channelId, "channelToken": context.vars.channelToken, "recipientId": context.vars.recipientId, "chatId": context.vars.channelId + '-' + context.vars.senderId, "senderId": context.vars.senderId }
});
return waitForResponse(context, events, done, startedAt, startTime);
}
function waitForResponse(context, events, done, startedAt, startTime) {
context.sockets["/"].on("message", function (res) {
if (res.action == "UNK") {
markEndTime(events, context, startedAt);
context.sockets["/"].off("message");
return done();
}
});
}
function markEndTime(ee, context, startedAt) {
let endedAt = process.hrtime(startedAt);
let delta = (endedAt[0] * 1e9) + endedAt[1];
ee.emit('response', delta, 0, context._uid);
}
from artillery-core.
Related Issues (20)
- Feature Proposal: File Upload HOT 6
- Artillery does not return with certain malformed requests
- Artillery is connecting twice with socket.io HOT 14
- Known vulnerability in npm dependancy ws. HOT 2
- Known vulnerability in npm dependancy tough-cookie
- Question/bug?: customStats being overwritten HOT 1
- beforeReqeust's requestParams can't be customized. HOT 1
- Send binary packet through WS? HOT 1
- WS get received data? HOT 1
- Add socketio query param on connect event HOT 3
- Match json fails for numeric value
- Variables with 0 numeric value are always empty string
- Expose http response body to afterResponse HOT 2
- Socket.IO Engine - Emit Callback Data HOT 1
- Double send in socket.io engine HOT 3
- Add raw TCP socket engine
- [Feature Request] Add support for SignalR
- supporting multipart form data HOT 4
- form not sending data HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from artillery-core.