I have an simple Deno app, which uses express and Mongodb. This app works perfect and inserts the record properly when I send request using Postman.
However, when I run a load test with Artillery, artillery gives error such as:
Warning: multiple batches of metrics for period 1696402250000 2023-10-04T06:50:50.000Z
All VUs finished. Total time: 10 seconds
--------------------------------
Summary report @ 09:51:01(+0300)
--------------------------------
errors.ECONNREFUSED: ........................................................... 10
http.request_rate: ............................................................. 1/sec
http.requests: ................................................................. 10
vusers.created: ................................................................ 10
vusers.created_by_name.Register: ............................................... 10
vusers.failed: ................................................................. 10
My index.ts:
import { MongoClient } from "npm:mongodb";
import express from "npm:express";
const url = "mongodb://127.0.0.1:27017/some-db";
const client = new MongoClient(url);
client.connect().then(() => console.log("Connected successfully to server")).catch(console.log("Error connecting to server"));
const db = client.db("some-db");
const collection = db.collection("users");
const app = express();
app.use(express.json());
app.post('/', async (req, res) => {
const savedUser = await collection.insertOne(req.body);
return res.send(200);
});
app.listen(3000, () => console.log('Server is running on 3000'));
My artillery file
config:
target: http://localhost:3000
phases:
- duration: 10
arrivalRate: 1
name: Warm up the API
scenarios:
- name: Register
flow:
- post:
url: "/"
json:
name: "John"
surname: "Doe"
birthday: "1990-01-01"
Any idea? Thanks in advance.
Some users of Artillery have reported this issue with Deno in the past here.
Try changing your target from
http://localhost:3000tohttp://127.0.0.1:3000and it should resolve it.