【问题标题】:JMeter - XMPP AuthenticationJMeter - XMPP 身份验证
【发布时间】:2017-09-12 14:58:39
【问题描述】:

我正在制定一个测试计划来使用 JMeter 测试 XMPP。但是,即使身份验证字符串正确,当我向服务器发送身份验证字符串时,我总是会遇到错误。有没有人有同样的问题或知道如何解决这个问题?谢谢。

2014/07/04 10:23:22 INFO  - jmeter.engine.StandardJMeterEngine: Running the test! 
2014/07/04 10:23:22 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(true,*local*) 
2014/07/04 10:23:22 INFO  - jmeter.engine.StandardJMeterEngine: Starting ThreadGroup: 1 : Thread Group 
2014/07/04 10:23:22 INFO  - jmeter.engine.StandardJMeterEngine: Starting 1 threads for group Thread Group. 
2014/07/04 10:23:22 INFO  - jmeter.engine.StandardJMeterEngine: Thread will continue on error 
2014/07/04 10:23:22 INFO  - jmeter.threads.ThreadGroup: Starting thread group number 1 threads 1 ramp-up 1 perThread 1000.0 delayedStart=false 
2014/07/04 10:23:22 INFO  - jmeter.threads.ThreadGroup: Started thread group number 1 
2014/07/04 10:23:22 INFO  - jmeter.engine.StandardJMeterEngine: All thread groups have been started 
2014/07/04 10:23:22 INFO  - jmeter.threads.JMeterThread: Thread started: Thread Group 1-1 
2014/07/04 10:23:22 ERROR - ru.yandex.jmeter.XMPPClientImpl: Error reading data java.lang.RuntimeException: Retries more than 1000, aborting read
at ru.yandex.jmeter.XMPPClientImpl.read(XMPPClientImpl.java:116)
at org.apache.jmeter.protocol.tcp.sampler.TCPSampler.sample(TCPSampler.java:414)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:428)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
at java.lang.Thread.run(Unknown Source)

2014/07/04 10:23:22 ERROR - jmeter.protocol.tcp.sampler.TCPSampler:  java.lang.RuntimeException: Error reading data
at ru.yandex.jmeter.XMPPClientImpl.read(XMPPClientImpl.java:152)
at org.apache.jmeter.protocol.tcp.sampler.TCPSampler.sample(TCPSampler.java:414)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:428)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.RuntimeException: Retries more than 1000, aborting read
at ru.yandex.jmeter.XMPPClientImpl.read(XMPPClientImpl.java:116)
... 4 more

2014/07/04 10:23:22 INFO  - jmeter.threads.JMeterThread: Thread finished: Thread Group 1-1 
2014/07/04 10:23:22 INFO  - jmeter.engine.StandardJMeterEngine: Notifying test listeners of end of test 
2014/07/04 10:23:22 INFO  - jmeter.gui.util.JMeterMenuBar: setRunning(false,*local*) 

【问题讨论】:

  • 能否展示您的测试计划,放大 XMPPSampler 并展示您的配置
  • @PMDUBIK-INGENIERIE dropbox.com/s/v8hlav0mdnmmhrw/xmpp.png 你可以参考链接查看我的配置。
  • 您曾经解决过这个问题吗?我在使用 XMPPClientImpl 插件时遇到了同样的问题。我已经添加了 BeanShell 侦听器,看看我是否可以获得任何额外的调试信息但没有用,我只是得到了你上面发布的无用信息。我要测试的服务器是 Openfire 聊天服务器,它的日志甚至没有显示来自 Jmeter 前端的任何连接尝试。我的下一步是使用 Wireshark 看看我是否可以在测试计划运行时获得任何有用的响应,但我不抱希望。

标签: xmpp jmeter


【解决方案1】:

我曾尝试使用 XMPPClientImpl 插件,但总是遇到同样的错误(“Retries more than 1000, aborting read”),所以我决定放弃它并编写自己的代码。

我使用 BeanShell 采样器,在其中运行以下代码(使用 smack 库)连接到 XMPP 服务器。

String CLASS_PATH = "C:/JMeter/apache-jmeter-2.13/lib/ext/smack/";

addClassPath(CLASS_PATH + "smack-android-extensions-4.1.3.jar");
addClassPath(CLASS_PATH + "smack-tcp-4.1.3.jar");
addClassPath(CLASS_PATH + "smack-android-4.1.3.jar");

// explicitly import every class you need 
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.ConnectionListener;

import org.jivesoftware.smack.tcp.XMPPTCPConnection;
import org.jivesoftware.smack.tcp.XMPPTCPConnectionConfiguration;

import org.jivesoftware.smack.SmackException;
import org.jivesoftware.smack.XMPPException;
import org.jivesoftware.smack.XMPPException.XMPPErrorException;

String jabberId = "...";
String jabberPass = "...";

String SERVER_ADDRESS = "...";
int    PORT =  5222;  // or any other port

XMPPTCPConnection getConnection() {

    XMPPTCPConnectionConfiguration config  = 
        XMPPTCPConnectionConfiguration.builder()
           .setUsernameAndPassword(jabberId, jabberPass)
           .setHost(SERVER_ADDRESS)
           .setServiceName(SERVER_ADDRESS)
           .setPort(DEFAULT_PORT)
        // .setSecurityMode(ConnectionConfiguration.SecurityMode.disabled)
           .setSendPresence(true)
        // .setDebuggerEnabled(YouMe.DEBUG)
           .build();

   XMPPTCPConnection con = new XMPPTCPConnection(config);

   int REPLY_TIMEOUT = 50000;  // 50 seconds, but can be shorter
   con.setPacketReplyTimeout(REPLY_TIMEOUT);

   return con;
}

不要忘记将 smack 路径(例如 C:\JMeter\apache-jmeter-2.13\lib\ext\smack)添加到库字段(在“添加目录或 jar 类路径 ") 在测试计划的测试计划节点中。

连接 -

con = getConnection();
con.connect();

登录 -

con.login(jabberId, jabberPass);

你也可以添加连接监听器 -

ConnectionListener listener = new ConnectionListener() {  

    public void  connected(XMPPConnection xmppConnection) {
            // run main code incl. the login code
            runMain();
    }
    public void  authenticated(XMPPConnection xmppConnection, boolean resumed) {
    }
    public void connectionClosed() {
    }
    public void  connectionClosedOnError(Exception e) {
    }
    public void  reconnectingIn(int i) {
    }
    public void  reconnectionSuccessful() {
    }
    public void reconnectionFailed(Exception e) {
    }
    }; 

con.addConnectionListener(listener);

// connect
con.connect();

runMain() {
    con.login(jabberId, jabberPass);

    // ...
}

【讨论】:

    猜你喜欢
    • 2014-10-31
    • 1970-01-01
    • 1970-01-01
    • 2017-06-13
    • 2017-03-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多