我正在为ajax仪表板开发JMeter脚本。用户登录,导航到存储库,单击仪表板链接,等待仪表板显示,然后注销。
仪表板有五个小面板。我已经在脚本中找到了一对点,其中有五对采样器,每个采样器一个。每对中的第一个采样器都有一个POST REST请求,主体中带有ajax。有一个正则表达式提取器,用于从响应主体中提取id。此id被添加到该对的第二个采样器中的URL中,该对象还具有在主体中具有ajax的POST REST请求。
当有一对或两对这些采样器时,脚本100%的时间工作,执行返回HTTP 200响应的采样器并正确地替换从每对中的第一个采样器中提取的id,然后在最终采样器中注销(exit.html)。当添加第三对采样器时,我每10-15次执行就会得到一次SocketException。启用四对后,它会更频繁地发生,并且启用第五对时,它会在100%的时间内发生。
奇怪的是,在logout采样器中发生了SocketException,没有其他采样器。此外,如果禁用注销采样器,则套接字异常永远不会发生,它会100%的时间工作。
这里是完整的堆栈跟踪:
java.net.SocketException: Socket closed
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1676)
at sun.net.www.protocol.http.HttpURLConnection$6.run(HttpURLConnection.java:1674)
at java.security.AccessController.doPrivileged(Native Method)
at sun.net.www.protocol.http.HttpURLConnection.getChainedException(HttpURLConnection.java:1672)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1245)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468)
at org.apache.jmeter.protocol.http.sampler.HTTPJavaImpl.readResponse(HTTPJavaImpl.java:258)
at org.apache.jmeter.protocol.http.sampler.HTTPJavaImpl.sample(HTTPJavaImpl.java:514)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.followRedirects(HTTPSamplerBase.java:1486)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.resultProcessing(HTTPSamplerBase.java:1561)
at org.apache.jmeter.protocol.http.sampler.HTTPAbstractImpl.resultProcessing(HTTPAbstractImpl.java:338)
at org.apache.jmeter.protocol.http.sampler.HTTPJavaImpl.sample(HTTPJavaImpl.java:588)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1141)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1130)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:431)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:258)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.SocketException: Socket closed
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.read(SocketInputStream.java:152)
at java.net.SocketInputStream.read(SocketInputStream.java:122)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275)
at java.io.BufferedInputStream.read(BufferedInputStream.java:334)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:689)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:633)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1324)
at sun.net.www.protocol.http.HttpURLConnection.getHeaderField(HttpURLConnection.java:2691)
at java.net.URLConnection.getHeaderFieldLong(URLConnection.java:639)
at java.net.URLConnection.getContentLengthLong(URLConnection.java:511)
at java.net.URLConnection.getContentLength(URLConnection.java:495)
at org.apache.jmeter.protocol.http.sampler.HTTPJavaImpl.readResponse(HTTPJavaImpl.java:224)
... 12 more
我很感激任何帮助调试这个
答案 0 :(得分:1)
我认为由于HTTP请求更改默认设置更改而导致您收到Socket Closed错误,包括
有关如何绕过它的详细说明和选项,请参阅Connection Reset since JMeter 2.10 ? wiki页面,如果您完全确定问题不在您的网络服务器上。
此外,发送单独的HTTP请求并不是测试AJAX应用程序的非常正确的方法,因为AJAX假定在同一父线程的范围内启动额外请求。当前JMeter实现不允许覆盖父线程组限制因此不可能使用一个线程一次产生多个请求。
查看How to Load Test AJAX/XHR Enabled Sites With JMeter指南,了解如何正确测试AJAX应用程序的选项。