Jmeter - Asnc 请求

Jmeter - Asnc request

如何模拟来自 JMeter 的异步请求。

从 Jmeter 发送请求 --> 发送到服务器 --> 服务器给出确认

现在我如何打开一个端口或 URL 服务器在完成他的内部 cycle/flow 后可以给我一个响应。以及我如何阅读回复。

您可以使用 JSR223 Sampler and write a simple TCP server in Groovy using ServerSocket,它将侦听传入的数据并执行您需要用它完成的任何操作。

将收到的消息打印到 jmeter.log file 的参考实现:

def socketServer = new ServerSocket(1234)

while (true) {
    socketServer.accept { socket ->
        socket.withStreams { input, output ->
            log.info("Received message: ${input.newReader().readLine()}")
        }
    }
}

实际效果如下:

当我使用 HTTP Raw Request sampler it's getting printed to the JMeter log file, similarly you can capture your server's callback, just make sure that the server can reach the machine where JMeter is running, i.e. it has static IP address, incoming traffic to the port of your choice is not blocked by a firewall 发送 hello 消息时你可以看到,等等