【问题标题】:JMeter SocketException when uploading 1GB file上传 1GB 文件时出现 JMeter SocketException
【发布时间】:2021-06-14 23:14:23
【问题描述】:

JMeter 5.4.1 OpenJDK 15.0.1

我的测试服务器默认配置为允许上传最大 1073741824 字节的文件,这是可配置的限制。我的目标是验证配置的限制是否得到遵守。

当我将其配置为 1048576 字节并在上传时超过该限制时,服务器会发送响应:

"{"type":"https://tools.ietf.org/html/rfc7231#section-6.5.1","title":"One or more validation errors occurred.","status":400,"traceId":"|bd37f36b-4cd68e1b8b433669.","errors":{"":["Failed to read the request form. Multipart body length limit 1048576 exceeded."]}}"

当我将其配置为 1073741824 字节并在上传时超过该限制时,JMeter 报告以下错误:

java.net.SocketException: Connection reset by peer
    at java.base/sun.nio.ch.NioSocketImpl.implWrite(NioSocketImpl.java:420)
    at java.base/sun.nio.ch.NioSocketImpl.write(NioSocketImpl.java:440)
    at java.base/sun.nio.ch.NioSocketImpl$2.write(NioSocketImpl.java:826)
    at java.base/java.net.Socket$SocketOutputStream.write(Socket.java:1051)
    at java.base/sun.security.ssl.SSLSocketOutputRecord.deliver(SSLSocketOutputRecord.java:342)
    at java.base/sun.security.ssl.SSLSocketImpl$AppOutputStream.write(SSLSocketImpl.java:1277)
    at org.apache.http.impl.io.SessionOutputBufferImpl.streamWrite(SessionOutputBufferImpl.java:124)
    at org.apache.http.impl.io.SessionOutputBufferImpl.flushBuffer(SessionOutputBufferImpl.java:136)
    at org.apache.http.impl.io.SessionOutputBufferImpl.write(SessionOutputBufferImpl.java:167)
    at org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:113)
    at org.apache.http.entity.mime.content.FileBody.writeTo(FileBody.java:121)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl$ViewableFileBody.writeTo(HTTPHC4Impl.java:1513)
    at org.apache.http.entity.mime.AbstractMultipartForm.doWriteTo(AbstractMultipartForm.java:134)
    at org.apache.http.entity.mime.AbstractMultipartForm.writeTo(AbstractMultipartForm.java:157)
    at org.apache.http.entity.mime.MultipartFormEntity.writeTo(MultipartFormEntity.java:113)
    at org.apache.http.impl.DefaultBHttpClientConnection.sendRequestEntity(DefaultBHttpClientConnection.java:156)
    at org.apache.http.impl.conn.CPoolProxy.sendRequestEntity(CPoolProxy.java:152)
    at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:238)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl$2.doSendRequest(HTTPHC4Impl.java:458)
    at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
    at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:272)
    at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:186)
    at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
    at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
    at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:935)
    at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:646)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:66)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1296)
    at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1285)
    at org.apache.jmeter.threads.JMeterThread.doSampling(JMeterThread.java:638)
    at org.apache.jmeter.threads.JMeterThread.executeSamplePackage(JMeterThread.java:558)
    at org.apache.jmeter.threads.JMeterThread.processSampler(JMeterThread.java:489)
    at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:256)
    at java.base/java.lang.Thread.run(Thread.java:832)

我的 JMeter.bat 文件的堆设置如下:

set HEAP=-Xms1g -Xmx4g -XX:MaxMetaspaceSize=256m

这看起来类似于去年 10 月的帖子,但没有建议/报告的解决方案。 SocketException after sending huge request via JMeter

【问题讨论】:

    标签: file-upload jmeter jvm


    【解决方案1】:

    Connection reset by peer 表示您的服务器已重置连接,因此您应该在服务器日志中寻找线索。

    我建议在 JMeter 方面做的唯一一件事是考虑切换到 HTTP Raw Request 采样器,它具有 streaming the file directly to the server without loading it to memory first 的不错功能,我认为当涉及多个负载测试时它会非常有用虚拟用户。有关详细信息,请参阅 JMeter 插件支持论坛上的 HTTP Raw Request for SOAP + MTOM 帖子。

    【讨论】:

    • 谢谢德米特里。根据我们发现的一些日志,它确实看起来是服务器,但我们仍在调查具体原因。非常感谢您为我指明了正确的方向!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-26
    • 2013-05-02
    • 2010-12-08
    • 2011-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多