IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 网络协议 -> [jmeter] TCP Sampler -> 正文阅读

[网络协议][jmeter] 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

The implementations behave as follows:

TCPClientImpl

This implementation is fairly basic. When reading the response, it reads until the end of line byte, if this is defined by setting the property?tcp.eolByte, otherwise until the end of the input stream. You can control charset encoding by setting?tcp.charset, which will default to Platform default encoding.

BinaryTCPClientImpl

This implementation converts the GUI input, which must be a hex-encoded string, into binary, and performs the reverse when reading the response. When reading the response, it reads until the end of message byte, if this is defined by setting the property?tcp.BinaryTCPClient.eomByte, otherwise until the end of the input stream.

LengthPrefixedBinaryTCPClientImpl

This implementation extends BinaryTCPClientImpl by prefixing the binary message data with a binary length byte. The length prefix defaults to 2 bytes. This can be changed by setting the property?tcp.binarylength.prefix.length.

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).

Usage of pre- and suffix

For example, if the prefix = "[" and the suffix = "]", then the following response:

[J28] XI123,23,GBP,CR

would have the response code?J28.Response codes in the range "400"-"499" and "500"-"599" are currently regarded as failures; all others are successful. [This needs to be made configurable!]

The login name/password are not used by the supplied TCP implementations.


Sockets are disconnected at the end of a test run.

Screenshot of Control-Panel of TCP Sampler

Parameters

Attribute

Description

Required

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.

No

ServerName or IP

Name or IP of TCP server

Yes

Port Number

Port to be used

Yes

Re-use connection

If selected, the connection is kept open. Otherwise it is closed when the data has been read.

Yes

Close connection

If selected, the connection will be closed after running the sampler.

Yes

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.

No

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.

No

Connect Timeout

Connect Timeout (milliseconds,?0?disables).

No

Response Timeout

Response Timeout (milliseconds,?0?disables).

No

Set NoDelay

See?java.net.Socket.setTcpNoDelay(). If selected, this will disable Nagle's algorithm, otherwise Nagle's algorithm will be used.

Yes

Text to Send

Text to be sent

Yes

Login User

User Name - not used by default implementation

No

Password

Password - not used by default implementation (N.B. this is stored unencrypted in the test plan)

No

^

JMS Publisher

JMS Publisher will publish messages to a given destination (topic/queue). For those not familiar with JMS, it is the J2EE specification for messaging. There are numerous JMS servers on the market and several open source options.

JMeter does not include any JMS implementation jar; this must be downloaded from the JMS provider and put in the lib directory

Screenshot of Control-Panel of JMS Publisher

Parameters

Attribute

Description

Required

Name

Descriptive name for this element that is shown in the tree.

use JNDI properties file

use?jndi.properties. Note that the file must be on the classpath - e.g. by updating the?user.classpath?JMeter property. If this option is not selected, JMeter uses the "JNDI Initial Context Factory" and "Provider URL" fields to create the connection.

Yes

JNDI Initial Context Factory

Name of the context factory

No

Provider URL

The URL for the JMS provider

Yes, unless using jndi.properties

Destination

The message destination (topic or queue name)

Yes

Setup

The destination setup type. With?At startup, the destination name is static (i.e. always same name during the test), with?Each sample, the destination name is dynamic and is evaluate at each sample (i.e. the destination name may be a variable)

Yes

Authentication

Authentication requirement for the JMS provider

Yes

User

User Name

No

Password

Password (N.B. this is stored unencrypted in the test plan)

No

Expiration

The expiration time (in milliseconds) of the message before it becomes obsolete. If you do not specify an expiration time, the default value is?0?(never expires).

No

Priority

The priority level of the message. There are ten priority levels from?0?(lowest) to?9?(highest). If you do not specify a priority level, the default level is?4.

No

Reconnect on error codes (regex)

Regular expression for JMSException error codes which force reconnection. If empty no reconnection will be done

No

Number of samples to aggregate

Number of samples to aggregate

Yes

Message source

?Where to obtain the message:

From File

means the referenced file will be read and reused by all samples. If file name changes it is reloaded since JMeter 3.0

Random File from folder specified below

means a random file will be selected from folder specified below, this folder must contain either files with extension?.dat?for Bytes Messages, or files with extension?.txt?or?.obj?for Object or Text messages

Text area

The Message to use either for Text or Object message

Yes

Message type

Text, Map, Object message or Bytes Message

Yes

Content encoding

?Specify the encoding for reading the message source file:

RAW:

No variable support from the file and load it with default system charset.

DEFAULT:

Load file with default system encoding, except for XML which relies on XML prolog. If the file contain variables, they will be processed.

Standard charsets:

The specified encoding (valid or not) is used for reading the file and processing variables

Yes

Use non-persistent delivery mode?

Whether to set?DeliveryMode.NON_PERSISTENT?(defaults to?false)

No

JMS Properties

The JMS Properties are properties specific for the underlying messaging system. You can setup the name, the value and the class (type) of value. Default type is?String. For example: for WebSphere 5.1 web services you will need to set the JMS Property targetService to test webservices through JMS.

No

For the MapMessage type, JMeter reads the source as lines of text. Each line must have 3 fields, delimited by commas. The fields are:

  • Name of entry
  • Object class name, e.g. "String" (assumes?java.lang?package if not specified)
  • Object string value

valueOf(String)

name,String,Example
size,Integer,1234

The Object message is implemented and works as follow:

  • Put the JAR that contains your object and its dependencies in?jmeter_home/lib/?folder
  • Serialize your object as XML using XStream
  • Either put result in a file suffixed with?.txt?or?.obj?or put XML content directly in Text Area

Note that if message is in a file, replacement of properties will not occur while it will if you use Text Area.

The following table shows some values which may be useful when configuring JMS:

Apache?ActiveMQValue(s)Comment
Context Factoryorg.apache.activemq.jndi.ActiveMQInitialContextFactory.
Provider URLvm://localhost
Provider URLvm:(broker:(vm://localhost)?persistent=false)Disable persistence
Queue ReferencedynamicQueues/QUEUENAMEDynamically define?the QUEUENAME to JNDI
Topic ReferencedynamicTopics/TOPICNAMEDynamically define?the TOPICNAME to JNDI

  网络协议 最新文章
使用Easyswoole 搭建简单的Websoket服务
常见的数据通信方式有哪些?
Openssl 1024bit RSA算法---公私钥获取和处
HTTPS协议的密钥交换流程
《小白WEB安全入门》03. 漏洞篇
HttpRunner4.x 安装与使用
2021-07-04
手写RPC学习笔记
K8S高可用版本部署
mySQL计算IP地址范围
上一篇文章      下一篇文章      查看所有文章
加:2022-07-17 16:57:20  更:2022-07-17 16:57:25 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/25 22:48:32-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码