在TCP Sampler中发送请求的EOL字节 [英] Sending EOL byte for request in TCP Sampler

查看:130
本文介绍了在TCP Sampler中发送请求的EOL字节的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我正在使用TCP套接字服务器,该服务器定义了基于文本的客户端服务器通信.我想使用jmeter的TCP Sampler来衡量该服务的性能,但是问题是我找不到为每个请求发送EOL字节的方法.从我看到的服务器定义"\ 0"作为行定界符.据我了解,行尾(EOL)字节值"字段用于解析服务器响应,并且在发出请求时不会考虑其值.

So, I am having TCP socket server which defines text based client server communication. I want to measure performance of this service using jmeter's TCP Sampler but the problem is that I cannot find a way to send EOL byte for every request. From what I see the server defines "\0" as line delimiter. From what I understand the field 'End of line(EOL) byte value' is for parsing server response and its value is not considered when request is being made.

使用以下代码,我可以连接到服务器,并且行定界符已正确解析:

Using the following code I am able to connect to my server and line delimiter is properly parsed:

NioSocketConnector connector = new NioSocketConnector();

TextLineCodecFactory customTextLineCodecFactory = new TextLineCodecFactory(Charset.forName("UTF-8"),
    LineDelimiter.NUL, LineDelimiter.NUL);

connector.getFilterChain().addLast("codec", new ProtocolCodecFilter(customTextLineCodecFactory));
connector.setHandler(this);
IoSession session;

for (;;) {
    try {
        ConnectFuture future = connector.connect(new 
        InetSocketAddress("127.0.0.1", 8090));
        future.awaitUninterruptibly();
        session = future.getSession();
        break;
    } catch (RuntimeIoException e) {
        System.err.println("Failed to connect");
        e.printStackTrace();
        Thread.sleep(5000);
    }
}

// wait until the summation is done
session.write("sth");
session.getCloseFuture().awaitUninterruptibly();
connector.dispose();

我正在使用 Apache Mina 库进行套接字通信.

I am using Apache Mina library for socket communication.

使用TCP采样器,我已连接到服务器,但是没有发送行定界符,并且服务器不知道数据包在何处结束.

With TCP Sampler I get connected to my server, but line delimiter is not sent and the server does not know where the packet ends.

我的问题是:如何使用TCP Sampler的默认TCPClientImpl发送行尾字节?

My question is: How do I send end of line byte using default TCPClientImpl of TCP Sampler?

推荐答案

在TCP Sampler中设置属性:

In TCP Sampler set the property:

tcp.eolByte=0

或者如果使用Java代码:

or if in Java code:

tcpClient.setEolByte(0);

...这将强制您的字符串EOL为 NULL字符串

... which will force your string EOLs to be NULL Strings

在屏幕下方,您会看到EOL字节值.

Below you can see EOL byte value on the right of the screen shoot.

这篇关于在TCP Sampler中发送请求的EOL字节的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆