问题
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();
I am using Apache Mina library for socket communication.
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.
My question is: How do I send end of line byte using default TCPClientImpl of TCP Sampler?
回答1:
In TCP Sampler set the property:
tcp.eolByte=0
or if in Java code:
tcpClient.setEolByte(0);
... which will force your string EOLs to be NULL Strings
Below you can see EOL byte value on the right of the screen shoot.
来源:https://stackoverflow.com/questions/51363303/sending-eol-byte-for-request-in-tcp-sampler