0

I have a java1.6 gateway application runs on aix. During the day millions of messages passing through successfully but when I look at logs I see a few logs like stacktrace below. log1:

java.net.SocketException: Invalid argument
    at java.io.DataOutputStream.write(DataOutputStream.java:119)
    at org.apache.commons.io.IOUtils.copy(IOUtils.java:921)
    at org.mule.providers.http.HttpServerConnection.writeResponse(HttpServerConnection.java:223)
    at com.ibtech.smg.esb.providers.esb.ESBHttpMessageReceiver$NewHttpWorker.run(ESBHttpMessageReceiver.java:162)
    at org.mule.impl.work.WorkerContext.run(WorkerContext.java:290)

log2:

java.net.SocketException: Invalid argument
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:125)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:171)
    at java.io.DataOutputStream.write(DataOutputStream.java:119)
    at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:234)
    at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:304)
    at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:308)
    at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:154)
    at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:288)
    at java.io.BufferedWriter.flush(BufferedWriter.java:266)
    at java.io.FilterWriter.flush(FilterWriter.java:112)
    at org.mule.providers.http.ResponseWriter.flush(ResponseWriter.java:75)

I have searched internet but none of the trace or case seem to be fit with mine. I have tried to generate situation in my development environment (on windows.) Tried big messages, closed socket situations, 0 size messages, but no luck. Can not see the same error. Do anybody has any clue why this error can occur ? This is a bug in application or os bug ?

4
  • Did you already try -Djava.net.preferIPv4Stack=true ? It seems to be a solution on similar questions. Commented Jul 1, 2015 at 13:36
  • @user140547 It would be nice if you could add a link to one of the similar questions Commented Jul 1, 2015 at 13:47
  • stackoverflow.com/questions/8216713/… stackoverflow.com/questions/3056399/eclipse-and-tomcat Commented Jul 1, 2015 at 13:50
  • I already saw that question, stack trace does not look like mine(I get error in writing to socket). and also I get this error very rare, but the question specifies a permanent error I think. Commented Jul 1, 2015 at 18:30

1 Answer 1

0

The problem (java.net.SocketException: Invalid argument) occurs when you try to write a buffer larger than 64K using SocketOutputStream.write(). When you use SocketOutputStream.write(), remenber use SocketOutputStream.flush() to clear SocketOutputStream.

Another situation, connection has closed by server. (use command 'netstat' to check status of your connection, will be 'CLOSE_WAIT') When you using SocketOutputStream.write(), log also dispaly "java.net.SocketException: Invalid argument".

REF_DOC

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.