简体   繁体   English

在TCP Sampler中发送请求的EOL字节

[英]Sending EOL byte for request in TCP Sampler

So, I am having TCP socket server which defines text based client server communication. 因此,我正在使用TCP套接字服务器,该服务器定义了基于文本的客户端服务器通信。 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. 我想使用jmeter的TCP Sampler来衡量该服务的性能,但是问题是我找不到为每个请求发送EOL字节的方法。 From what I see the server defines "\\0" as line delimiter. 从我看到的服务器定义“ \\ 0”作为行定界符。 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. 据我了解,“行尾(EOL)字节值”字段用于解析服务器响应,并且在发出请求时不考虑其值。

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();

I am using Apache Mina library for socket communication. 我正在使用Apache Mina库进行套接字通信。

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,我已连接到服务器,但是没有发送行定界符,并且服务器不知道数据包在何处结束。

My question is: How do I send end of line byte using default TCPClientImpl of TCP Sampler? 我的问题是:如何使用TCP Sampler的默认TCPClientImpl发送行尾字节?

In TCP Sampler set the property: 在TCP Sampler中设置属性:

tcp.eolByte=0

or if in Java code: 或如果使用Java代码:

tcpClient.setEolByte(0);

... which will force your string EOLs to be NULL Strings ...这将强制您的字符串EOL为NULL字符串

Below you can see EOL byte value on the right of the screen shoot. 在下方,您可以在屏幕截图的右侧看到EOL字节值。

EOL在右边

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM