I'm facing a very strange error when consuming SOAP WebServices. The strange this here is that, the client works fine against the test server, but when trying against the production server, it fails with a read time out:
[com.ctc.wstx.exc.WstxLazyException] Read timed out
What is even strange is that the same SOAP client code base that I have on production, when run locally on my machine against the production SOAP WebService server runs perfectly fine. It is only on our production client environment to the production SOAP WebService server fails with this exception. I'm totally clueless on this and I have been trying to get to the root of this problem with one of my network colleague for the past 4 hours with no success. Any clues?
I'm using Apache CXF!
This was a very hard problem to solve. Here is the exception that I got:
Caused by: com.ctc.wstx.exc.WstxIOException: Read timed out
at com.ctc.wstx.sr.StreamScanner.constructFromIOE(StreamScanner.java:633) ~[org.codehaus.woodstox.woodstox-core-asl-4.4.1.jar:4.4.1]
at com.ctc.wstx.sr.StreamScanner.loadMore(StreamScanner.java:1007) ~[org.codehaus.woodstox.woodstox-core-asl-4.4.1.jar:4.4.1]
at com.ctc.wstx.sr.BasicStreamReader.readTextSecondary(BasicStreamReader.java:4647) ~[org.codehaus.woodstox.woodstox-core-asl-4.4.1.jar:4.4.1]
at com.ctc.wstx.sr.BasicStreamReader.finishToken(BasicStreamReader.java:3722) ~[org.codehaus.woodstox.woodstox-core-asl-4.4.1.jar:4.4.1]
at com.ctc.wstx.sr.BasicStreamReader.safeFinishToken(BasicStreamReader.java:3676) ~[org.codehaus.woodstox.woodstox-core-asl-4.4.1.jar:4.4.1]
... 39 common frames omitted
Caused by: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method) ~[na:1.7.0_51]
at java.net.SocketInputStream.read(SocketInputStream.java:152) ~[na:1.7.0_51]
at java.net.SocketInputStream.read(SocketInputStream.java:122) ~[na:1.7.0_51]
at java.io.BufferedInputStream.fill(BufferedInputStream.java:235) ~[na:1.7.0_51]
at java.io.BufferedInputStream.read1(BufferedInputStream.java:275) ~[na:1.7.0_51]
at java.io.BufferedInputStream.read(BufferedInputStream.java:334) ~[na:1.7.0_51]
at sun.net.www.http.ChunkedInputStream.readAheadBlocking(ChunkedInputStream.java:552) ~[na:1.7.0_51]
at sun.net.www.http.ChunkedInputStream.readAhead(ChunkedInputStream.java:609) ~[na:1.7.0_51]
at sun.net.www.http.ChunkedInputStream.read(ChunkedInputStream.java:696) ~[na:1.7.0_51]
at java.io.FilterInputStream.read(FilterInputStream.java:133) ~[na:1.7.0_51]
at sun.net.www.protocol.http.HttpURLConnection$HttpInputStream.read(HttpURLConnection.java:3053) ~[na:1.7.0_51]
at com.ctc.wstx.io.BaseReader.readBytes(BaseReader.java:155) ~[org.codehaus.woodstox.woodstox-core-asl-4.4.1.jar:4.4.1]
at com.ctc.wstx.io.UTF8Reader.loadMore(UTF8Reader.java:368) ~[org.codehaus.woodstox.woodstox-core-asl-4.4.1.jar:4.4.1]
at com.ctc.wstx.io.UTF8Reader.read(UTF8Reader.java:111) ~[org.codehaus.woodstox.woodstox-core-asl-4.4.1.jar:4.4.1]
at com.ctc.wstx.io.MergedReader.read(MergedReader.java:105) ~[org.codehaus.woodstox.woodstox-core-asl-4.4.1.jar:4.4.1]
at com.ctc.wstx.io.ReaderSource.readInto(ReaderSource.java:86) ~[org.codehaus.woodstox.woodstox-core-asl-4.4.1.jar:4.4.1]
at com.ctc.wstx.io.BranchingReaderSource.readInto(BranchingReaderSource.java:56) ~[org.codehaus.woodstox.woodstox-core-asl-4.4.1.jar:4.4.1]
at com.ctc.wstx.sr.StreamScanner.loadMore(StreamScanner.java:1001) ~[org.codehaus.woodstox.woodstox-core-asl-4.4.1.jar:4.4.1]
... 42 common frames omitted
Keep in mind that the WstxIOException points to the application not being able to parse the incoming SOAP message. In our case, the SOAP message was sent in chunks by the server and our application was not receiving all the chunks. There was some network firewall which was discarding some packets that were larger than 1024kb. This was happening on the tcp level.
As soon as our network guys increased the size of the incoming packets, it started to work instantly!