title: java.nio.channels.ClosedChannelException -Client shuts down SSL
body: <p>HI,</p>
  
  <p>I have a webservice running on glassfish3.1 server on one machine.</p>
  
  <p>On second machine I have a java (GUI) app, that is running and calls the above mentioned web service.</p>
  
  <p>In my webservice call, i send a file as SOAP attachment. It reaches the server, the file is then processed and then it is returned back to my client machine over https.</p>
  
  <p>If my file is too large and takes more than 15 mins, the operation fails and I get the following error:</p>
  
  <p>On Client side: 
  <strong>Couldn't create SOAP message due to exception: org.jvnet.mimepull.MIMEParsingException: javax.net.ssl.SSLException: SSL peer shut down incorrectly</strong></p>
  
  <p>on server side:
  <strong>javax.servlet.ServletException
          at org.glassfish.webservices.JAXWSServlet.doPost(JAXWSServlet.java:150)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:755)
          at javax.servlet.http.HttpServlet.service(HttpServlet.java:848)
          at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1534)
          at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)
          at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)
          at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)
          at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)
          at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)
          at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)
          at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)
          at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:326)
          at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:227)
          at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:170)
          at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:822)
          at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:719)
          at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1013)
          at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)
          at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)
          at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)
          at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)
          at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)
          at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)
          at com.sun.grizzly.ContextTask.run(ContextTask.java:71)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)
          at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)
          at java.lang.Thread.run(Thread.java:662)
  Caused by: javax.xml.ws.WebServiceException: com.ctc.wstx.exc.WstxIOException: java.nio.channels.ClosedChannelException
          at com.sun.xml.ws.encoding.MtomCodec.encode(MtomCodec.java:184)
          at com.sun.xml.ws.encoding.SOAPBindingCodec.encode(SOAPBindingCodec.java:282)
          at com.sun.xml.ws.transport.http.HttpAdapter.encodePacket(HttpAdapter.java:400)
          at com.sun.xml.ws.transport.http.HttpAdapter.access$100(HttpAdapter.java:96)
          at com.sun.xml.ws.transport.http.HttpAdapter$HttpToolkit.handle(HttpAdapter.java:618)
          at com.sun.xml.ws.transport.http.HttpAdapter.handle(HttpAdapter.java:259)
          at com.sun.xml.ws.transport.http.servlet.ServletAdapter.handle(ServletAdapter.java:162)
          at org.glassfish.webservices.JAXWSServlet.doPost(JAXWSServlet.java:145)
          ... 27 more
  Caused by: com.ctc.wstx.exc.WstxIOException: java.nio.channels.ClosedChannelException
          at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:313)
          at com.sun.xml.ws.util.xml.XMLStreamWriterFilter.flush(XMLStreamWriterFilter.java:71)
          at com.sun.xml.ws.streaming.XMLStreamWriterUtil.getOutputStream(XMLStreamWriterUtil.java:101)
          at com.sun.xml.ws.message.jaxb.JAXBMessage.writePayloadTo(JAXBMessage.java:320)
          at com.sun.xml.ws.message.AbstractMessageImpl.writeTo(AbstractMessageImpl.java:147)
          at com.sun.xml.ws.encoding.MtomCodec.encode(MtomCodec.java:168)
          ... 34 more
  Caused by: org.apache.catalina.connector.ClientAbortException: java.nio.channels.ClosedChannelException
          at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:382)
          at org.apache.catalina.connector.OutputBuffer.flush(OutputBuffer.java:351)
          at org.apache.catalina.connector.CoyoteOutputStream.flush(CoyoteOutputStream.java:175)
          at com.ctc.wstx.io.UTF8Writer.flush(UTF8Writer.java:99)
          at com.ctc.wstx.sw.BufferingXmlWriter.flush(BufferingXmlWriter.java:214)
          at com.ctc.wstx.sw.BaseStreamWriter.flush(BaseStreamWriter.java:311)
          ... 39 more
  Caused by: java.nio.channels.ClosedChannelException
          at sun.nio.ch.SocketChannelImpl.ensureWriteOpen(SocketChannelImpl.java:133)
          at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:324)
          at com.sun.grizzly.util.OutputWriter.flushChannel(OutputWriter.java:108)
          at com.sun.grizzly.util.OutputWriter.flushChannel(OutputWriter.java:76)
          at com.sun.grizzly.util.SSLOutputWriter.flushChannel(SSLOutputWriter.java:102)
          at com.sun.grizzly.ssl.SSLOutputBuffer.flushChannel(SSLOutputBuffer.java:138)
          at com.sun.grizzly.http.SocketChannelOutputBuffer.flushBuffer(SocketChannelOutputBuffer.java:398)
          at com.sun.grizzly.http.SocketChannelOutputBuffer.flush(SocketChannelOutputBuffer.java:376)
          at com.sun.grizzly.http.ProcessorTask.action(ProcessorTask.java:1241)
          at com.sun.grizzly.ssl.SSLProcessorTask.action(SSLProcessorTask.java:164)
          at com.sun.grizzly.tcp.Response.action(Response.java:268)
          at org.apache.catalina.connector.OutputBuffer.doFlush(Output</strong></p>
  
  <p>...</p>
  
  <p>I think that SSL session is timed out on my client side and not on the server side.</p>
  
  <p>Now I am trying to figure out a way to increase the SSL timeout on my client side which i suppose is 15 mins...</p>
  
  <p>I am not able to do so, any help would be appriciated...
  Thank you</p>