0

I have simple servlet on JBoss 5.1. When writing response a have no exception if connection closed. Connection closed by read timeout, from outside.

JBoss receives FIN, ACK, answers with ACK and after several seconds sends my response (PSH,ACK) and receives RST.

How to determine in servlet, that connection is closed and/or response is not writtеn successfully?

Rustam
  • 1,397
  • 1
  • 13
  • 17
  • When writing large data (500-600 Kb) to response I receive java.net.SocketException: Broken pipe – Rustam Oct 31 '13 at 11:41
  • Found solution. I set socketBuffer to -1 for JBoss connector, by default its 9000 bytes. How will this affect the performance of Jboss? – Rustam Oct 31 '13 at 12:41
  • Turning off out buffer helps only on local connections. Because without buffer response split on 2 parts - header and body, and JBoss receives RST after sending header, so we have exception when sending body. On network JBoss sends 3 packets (header, body, FIN) and receives three RST. – Rustam Oct 31 '13 at 13:31

1 Answers1

0

If you write enough data so that you are still writing after the RST arrives you will get an IOException: 'connection reset by peer'. TCP buffering and asynchronous writing means that this may not happen for a small write.

user207421
  • 305,947
  • 44
  • 307
  • 483
  • I'm writing before RST, and after FIN from client. The problem is that JBoss dont fully disconnect when receives FIN and allow to write response without exception. – Rustam Oct 31 '13 at 07:09