无法通过JMeter发送HTTP2请求

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了无法通过JMeter发送HTTP2请求相关的知识,希望对你有一定的参考价值。

我正在尝试通过JMeter发送HTTP2请求。I use the following request configuration:

我已根据我的Java版本下载了alpn-boot文件:Java版本“ 1.8.0_151”-> ALPN版本为8.1.11.v20170118(根据https://www.eclipse.org/jetty/documentation/9.4.x/alpn-chapter.html#alpn-versions)。另外,我已经将alpn-boot文件的路径添加到jmeter.bat:

set JVM_ARGS= -Xbootclasspath/p:D:apache-jmeter-5.1apache-jmeter-5.1libalpn-boot-8.1.11.v20170118.jar
@echo off

rem   Licensed to the Apache Software Foundation (ASF) under one or more
rem   contributor license agreements.  See the NOTICE file distributed with
...

但是我在JMeter中收到一条错误消息:

java.util.concurrent.ExecutionException: java.lang.IllegalStateException: No Client ALPNProcessors!
    at org.eclipse.jetty.util.FuturePromise.get(FuturePromise.java:138)
    at com.blazemeter.jmeter.http2.sampler.HTTP2Connection.connect(HTTP2Connection.java:69)
    at com.blazemeter.jmeter.http2.sampler.HTTP2Request.setConnection(HTTP2Request.java:280)
    at com.blazemeter.jmeter.http2.sampler.HTTP2Request.sample(HTTP2Request.java:140)
    at com.blazemeter.jmeter.http2.sampler.HTTP2Request.sample(HTTP2Request.java:117)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:475)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:418)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:249)
    at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.IllegalStateException: No Client ALPNProcessors!
    at org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory.<init>(ALPNClientConnectionFactory.java:57)
    at org.eclipse.jetty.http2.client.HTTP2Client.lambda$doStart$1(HTTP2Client.java:155)
    at org.eclipse.jetty.http2.client.HTTP2Client$ClientSelectorManager.newConnection(HTTP2Client.java:438)
    at org.eclipse.jetty.io.ManagedSelector.createEndPoint(ManagedSelector.java:222)
    at org.eclipse.jetty.io.ManagedSelector.access$1500(ManagedSelector.java:60)
    at org.eclipse.jetty.io.ManagedSelector$CreateEndPoint.run(ManagedSelector.java:825)
    at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:754)
    at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:672)
    ... 1 more
    Suppressed: java.lang.NoClassDefFoundError: org/eclipse/jetty/alpn/ALPN
        at org.eclipse.jetty.alpn.java.client.OpenJDK8ClientALPNProcessor.init(OpenJDK8ClientALPNProcessor.java:42)
        at org.eclipse.jetty.alpn.client.ALPNClientConnectionFactory.<init>(ALPNClientConnectionFactory.java:77)
        ... 8 more
    Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.alpn.ALPN
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        ... 10 more

我想这个问题与jmeter.bat文件中的alpn路径有关,但是如何解决?

答案
  1. 首先确保JMeter使用Java 1.8.0_151并采用-Xbootclasspath参数,您可以通过添加JSR223 Sampler并使用以下Groovy代码来做到这一点:

    log.info('Java version: ' + System.getProperty('java.version')) java.lang.management.ManagementFactory.getRuntimeMXBean().getInputArguments().each { log.info("Effective JVM argument: " + "$it") }

    您应该获得如下输出:

    enter image description here

  2. 检查alpn-boot文件是否在[[真正:

    enter image description here

  3. 清理输入,即删除空格,在末尾添加分号,并用引号引起来的值:

  4. set JVM_ARGS="-Xbootclasspath/p:D:apache-jmeter-5.1apache-jmeter-5.1libalpn-boot-8.1.11.v20170118.jar;"
  5. 如果一切顺利,您应该能够成功执行HTTP2请求:
  6. enter image description here

更多信息:The New HTTP/2 Plugin for JMeter

以上是关于无法通过JMeter发送HTTP2请求的主要内容,如果未能解决你的问题,请参考以下文章

HTTP2 请求示例使用 Jmeter4 崩溃,Java 10 No Client ALPNProcessors

请求超时 - JMeter HTTP2 插件

无法向 Apache 服务器发出 http2 请求,尽管服务器在响应标头中发送“升级:h2”

如何使用 Node.js 通过代理发送 HTTP/2 请求?

我无法使用 RegisterActivityForResult 发送请求代码

使用 JMeter 的 HTTP/2 请求因“nullSession”而失败 (jetty-alpn)