Artillery 出现错误。Deno 服务器上的 ECONNREFUSED

问题描述 投票:0回答:1

我有一个简单的 Deno 应用程序,它使用 Express 和 Mongodb。 这个应用程序运行完美,当我使用 Postman 发送请求时可以正确插入记录

但是,当我使用 Artillery 运行负载测试时,artillery 会给出如下错误:

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

我的索引.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'));

我的火炮档案

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"

有什么想法吗?预先感谢。

mongodb load-testing deno artillery
1个回答
0
投票

Artillery 的一些用户过去曾报告过此问题此处

尝试将目标从

http://localhost:3000
更改为
http://127.0.0.1:3000
,应该可以解决问题。

© www.soinside.com 2019 - 2024. All rights reserved.