phax / as2-lib

A generic Java AS2 library, servlet and server
107 stars 43 forks source link

socket timeout exception, but file sent #23

Closed fiorenzino closed 7 years ago

fiorenzino commented 8 years ago

Hi Philip, using your library sometimes we have this error:

com.helger.as2lib.exception.OpenAS2Exception OpenAS2 WrappedOpenAS2Exception terminated: java.net.SocketTimeoutException: Read timed out; sources: {message=[AS2Message@0x107cf2de: data=javax.mail.internet.MimeBodyPart@6fbf0b80; MDN=null]}: java.net.SocketTimeoutException: Read timed out
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:170)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at sun.security.ssl.InputRecord.read(InputRecord.java:503)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:973)
at sun.security.ssl.SSLSocketImpl.readDataRecord(SSLSocketImpl.java:930)
at sun.security.ssl.AppInputStream.read(AppInputStream.java:105)
at java.io.BufferedInputStream.fill(BufferedInputStream.java:246)
at java.io.BufferedInputStream.read1(BufferedInputStream.java:286)
at java.io.BufferedInputStream.read(BufferedInputStream.java:345)
at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:704)
at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:647)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1536)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1441)
at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
at sun.net.www.protocol.https.HttpsURLConnectionImpl.getResponseCode(HttpsURLConnectionImpl.java:338)
at com.helger.as2lib.processor.sender.AS2SenderModule._sendViaHTTP(AS2SenderModule.java:635)
at com.helger.as2lib.processor.sender.AS2SenderModule.handle(AS2SenderModule.java:706)
at com.helger.as2lib.client.AS2Client.sendSynchronous(AS2Client.java:318)
at com.helger.peppol.as2client.AS2ClientBuilder.sendSynchronous(AS2ClientBuilder.java:983)
at com.jpeppol.as2sender.service.As2SenderService.process(As2SenderService.java:250)

But the file is received correctly. Did you experience this?

thanks in advance Fiorenzo Pizza

phax commented 8 years ago

This maybe resolved by finally implementing https://github.com/phax/as2-server/issues/10

We're just receiving files, but we're not sending anything. Do you have a proxy inbetween? Do you think by switching to httpclient this can be resolved?

// Philip

fiorenzino commented 8 years ago

Hi Philip, no proxy in my case. We send DESPATCH_ADVICESs or INVOICEs and we receive ORDERs. Yes, the use of httpclient could help. Starting from your code, I would like to create a simple As2 client (prototype), with only this functionality. i will share if you want.

Fiorenzo

phax commented 8 years ago

Hi Fiorenzo!

Any sharing is welcome :) You could maybe fork it and create a PR??

Btw. shall we have a short Skype talk on these issues (also the Wildfly one)?

// Philip

fiorenzino commented 8 years ago

Hi Philip, can we share our mail? Edited: done :)

Fiorenzo

phax commented 8 years ago

You've got a mail

tellouze commented 8 years ago

Hello, Is this issue is still open ? we are facing the same problem with our partners ? but we are behind a proxy. Thanks Toufik

phax commented 8 years ago

Hi. I could never reproduce the error :( Did you try increasing the read-timeout? Maybe some special HTTP headers for the proxy are needed????

tellouze commented 8 years ago

Hi Philip, How can I increase the read timeout ? Thanks

phax commented 8 years ago

Hi! This is currently a little pain in the ass (must be an attribute in the message). I will make this configurable in the AS2ClientSettings for 3.0.2

phax commented 8 years ago

I added AS2ClientSettings.setConnectTimeoutMS(int) and AS2ClientSettings.setReadTimeoutMS(int) methods in 3.0.2-SNAPSHOT

tellouze commented 8 years ago

Great! thank you.

tellouze commented 8 years ago

Hi Philip, Using 3.0.2-SNAPSHOT I tried to increase the timeout but it seems that it's not taken into account. It's always using the value by default 60s. Could you give a check please ? Thanks.

phax commented 8 years ago

Mea culpa. I set the attribute at the message instead of the sender module. Fixed in latest SNAPSHOT (on server in a few minutes)