SPONSORS:






View RSS Feed

Ronak

Understanding JMeter Element- TCP Sampler

Rate this Entry
by , 06-21-2015 at 02:17 AM (1718 Views)
Understanding JMeter Element- TCP Sampler

The TCP Sampler opens a TCP/IP connection to the specified server. It then sends the text, and waits for a response.

If "Re-use connection" is selected, connections are shared between Samplers in the same thread, provided that the exact same host name string and port are used. Different hosts/port combinations will use different connections, as will different threads. If both of "Re-use connection" and "Close connection" are selected, the socket will be closed after running the sampler. On the next sampler, another socket will be created. You may want to close a socket at the end of each thread loop.
If an error is detected - or "Re-use connection" is not selected - the socket is closed. Another socket will be reopened on the next sample.

The following properties can be used to control its operation:
tcp.status.prefix - text that precedes a status number
tcp.status.suffix - text that follows a status number
tcp.status.properties - name of property file to convert status codes to messages
tcp.handler - Name of TCP Handler class (default TCPClientImpl) - only used if not specified on the GUI

The class that handles the connection is defined by the GUI, failing that the property tcp.handler. If not found, the class is then searched for in the package org.apache.jmeter.protocol.tcp.sampler.
Users can provide their own implementation. The class must extend org.apache.jmeter.protocol.tcp.sampler.TCPClient.

The following implementations are currently provided.
TCPClientImpl
BinaryTCPClientImpl
LengthPrefixedBinaryTCPClientImpl

Timeout handling If the timeout is set, the read will be terminated when this expires. So if you are using an eolByte/eomByte, make sure the timeout is sufficiently long, otherwise the read will be terminated early.

Response handling

If tcp.status.prefix is defined, then the response message is searched for the text following that up to the suffix. If any such text is found, it is used to set the response code. The response message is then fetched from the properties file (if provided).
Sockets are disconnected at the end of a test run.


Parameters
Name- Descriptive name for this element that is shown in the tree.
TCPClient classname- Name of the TCPClient class. Defaults to the property tcp.handler, failing that TCPClientImpl.
ServerName or IP- Name or IP of TCP server
Port Number- Port to be used
Re-use connection- If selected, the connection is kept open. Otherwise it is closed when the data has been read.
Close connection- If selected, the connection will be closed after running the sampler.
SO_LINGER- Enable/disable SO_LINGER with the specified linger time in seconds when a socket is created. If you set "SO_LINGER" value as 0, you may prevent large numbers of sockets sitting around with a TIME_WAIT status.
End of line(EOL) byte value- Byte value for end of line, set this to a value outside the range -128 to +127 to skip eol checking. You may set this in jmeter.properties file as well with eolByte property. If you set this in TCP Sampler Config and in jmeter.properties file at the same time, the setting value in the TCP Sampler Config will be used.
Connect Timeout- Connect Timeout (milliseconds, 0 disables).
Response Timeout- Response Timeout (milliseconds, 0 disables).
Set Nodelay- See java.net.Socket.setTcpNoDelay(). If selected, this will disable Nagle's algorithm, otherwise Nagle's algorithm will be used.
Text to Send- Text to be sent
Login User- User Name - not used by default implementation
Password- Password - not used by default implementation



Disclaimer: The article/post is posted with the purpose of sharing knowledge and information.
The article may contain references, extract or content from other informative sources.
Researched/Authored/Compiled by -
Ronak Shah
Practice Head - Software Testing (QA), CIGNEX Datamatics

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 02:17 AM.

Copyright BetaSoft Inc.