title: Jmeter connection reset by Peer: socket write error/ socket exception: connection reset
body: <p>I have a performance test that is running in jmeter on a win7 machine. </p>
  
  <p>The performance test is comprised of 2 threads groups( user1, user2) and each thread makes 40 requests to a website using http request modules. </p>
  
  <p><strong>Test layout:</strong> 
  2 threads groups each containing 40 requests ( including 5 file uploads),cookie manager. </p>
  
  <p>I ran this test with 50 threads on each thread group and I keep getting errors.</p>
  
  <p><strong><em>Error Stack trace:</em></strong> </p>
  
  <p><strong>Error 1</strong> - <code>java.net.SocketException: Connection reset by peer: socket write error
          at java.net.SocketOutputStream.socketWrite0(Native Method)
      at java.net.SocketOutputStream.socketWrite(Unknown Source)
      at java.net.SocketOutputStream.write(Unknown Source)
      at sun.security.ssl.OutputRecord.writeBuffer(Unknown Source)
      at sun.security.ssl.OutputRecord.write(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.writeRecordInternal(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.writeRecord(Unknown Source)
      at sun.security.ssl.AppOutputStream.write(Unknown Source)
      at org.apache.http.impl.io.AbstractSessionOutputBuffer.write(AbstractSessionOutputBuffer.java:169)
      at org.apache.http.impl.io.ContentLengthOutputStream.write(ContentLengthOutputStream.java:119)
      at org.apache.http.entity.mime.content.FileBody.writeTo(FileBody.java:97)
      at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl$ViewableFileBody.writeTo(HTTPHC4Impl.java:896)
      at org.apache.http.entity.mime.HttpMultipart.doWriteTo(HttpMultipart.java:206)
      at org.apache.http.entity.mime.HttpMultipart.writeTo(HttpMultipart.java:224)
      at org.apache.http.entity.mime.MultipartEntity.writeTo(MultipartEntity.java:183)
      at org.apache.http.entity.HttpEntityWrapper.writeTo(HttpEntityWrapper.java:98)
      at org.apache.http.impl.client.EntityEnclosingRequestWrapper$EntityWrapper.writeTo(EntityEnclosingRequestWrapper.java:108)
      at org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:122)
      at org.apache.http.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:271)
      at org.apache.http.impl.conn.ManagedClientConnectionImpl.sendRequestEntity(ManagedClientConnectionImpl.java:197)
      at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:257)
      at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:125)
      at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:715)
      at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:520)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
      at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:481)
      at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:298)
      at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
      at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1105)
      at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1094)
      at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:429)
      at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257)
      at java.lang.Thread.run(Unknown Source)</code></p>
  
  <p><strong>Error 2</strong> - <code>java.net.SocketException: Connection reset
      at java.net.SocketInputStream.read(Unknown Source)
      at java.net.SocketInputStream.read(Unknown Source)
      at sun.security.ssl.InputRecord.readFully(Unknown Source)
      at sun.security.ssl.InputRecord.read(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
      at sun.security.ssl.SSLSocketImpl.readDataRecord(Unknown Source)
      at sun.security.ssl.AppInputStream.read(Unknown Source)
      at org.apache.http.impl.io.AbstractSessionInputBuffer.fillBuffer(AbstractSessionInputBuffer.java:166)
      at org.apache.http.impl.io.SocketInputBuffer.fillBuffer(SocketInputBuffer.java:90)
      at org.apache.http.impl.io.AbstractSessionInputBuffer.readLine(AbstractSessionInputBuffer.java:281)
      at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:92)
      at org.apache.http.impl.conn.DefaultHttpResponseParser.parseHead(DefaultHttpResponseParser.java:61)
      at org.apache.http.impl.io.AbstractMessageParser.parse(AbstractMessageParser.java:254)
      at org.apache.http.impl.AbstractHttpClientConnection.receiveResponseHeader(AbstractHttpClientConnection.java:289)
      at org.apache.http.impl.conn.DefaultClientConnection.receiveResponseHeader(DefaultClientConnection.java:252)
      at org.apache.http.impl.conn.ManagedClientConnectionImpl.receiveResponseHeader(ManagedClientConnectionImpl.java:191)
      at org.apache.http.protocol.HttpRequestExecutor.doReceiveResponse(HttpRequestExecutor.java:300)
      at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:127)
      at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:715)
      at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:520)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:906)
      at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:805)
      at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.executeRequest(HTTPHC4Impl.java:481)
      at org.apache.jmeter.protocol.http.sampler.HTTPHC4Impl.sample(HTTPHC4Impl.java:298)
      at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:74)
      at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1105)
      at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1094)
      at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:429)
      at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:257)
      at java.lang.Thread.run(Unknown Source)</code></p>
  
  <p>When I run the test at 25 threads I don't get these Errors.<code>enter code here</code></p>
  
  <p>I have tried to change settings in the properties file and I have also tried adding:
  <strong>set IPV4=-Djava.net.preferIPv4Stack=true and set ARGS=%DUMP% %HEAP% %NEW% %SURVIVOR% %TENURING% %PERM% %DDRAW% %IPV4%</strong> to jmeter.bat but I still get the errors..</p>
  
  <p>Please help..What could cause these errors? How do I fix them?  any help is greatly appreciated =)</p>