Repository navigation
Honour the sender's readtimeout and allow send timeouts per partnership - #636
Open
JakeHuneau wants to merge 1 commit into
Open
JakeHuneau wants to merge 1 commit into
JakeHuneau wants to merge 1 commit into
Conversation
The AS2 sender's "readtimeout" had no effect. PR OpenAS2#208 found it mapped to the wrong HttpClient setting (the connection request timeout) and replaced it with "sockettimeout", but the shipped config.xml and HowTo section 17.9 still set "readtimeout", which HttpSenderModule kept reading into the options and HTTPUtil never applied. Neither "sockettimeout" nor "connecttimeout" is set by the shipped configuration, so every send used the 60 second defaults whatever readtimeout said, and a partner that takes longer than that to return a synchronous MDN could not be accommodated by following the documentation. "readtimeout" is now used as the socket timeout when "sockettimeout" is not set; "sockettimeout" takes precedence when both are. A partnership can also set its own "connecttimeout" and "sockettimeout" attributes, in milliseconds, through a new HttpSenderModule.getHttpOptions( Partnership) used by both the AS2 sender and the asynchronous MDN sender, so one slow partner can be given longer without raising the timeout for every partner. A value that is not a non-negative number is ignored with a warning naming the partnership, rather than failing every send to that partner when the request is built. The sample openas2.properties sets module.AS2SenderModule.readtimeout to 3000000 (50 minutes); that value now takes effect for anyone who copied it, which the changelog points out. SendTimeoutTest covers how the options are worked out, and sends a real message through AS2SenderModule to a local partner that takes 3 seconds to answer: a 400ms partnership socket timeout ends the send well before that, and without one the send waits for the answer. The test and InterruptedSendReportStartupTest now use storage folders of their own, since the test configuration's pending folders are shared between test classes and the files one leaves there changed what the other's report could conclude.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The AS2 sender's
readtimeouthas no effect, so a partner that takes longer than 60 seconds to return a synchronous MDN cannot be accommodated by following the documentation.readtimeoutmapped to the wrong HttpClient setting (the connection request timeout) and replaced it withsockettimeoutinHTTPUtil.buildRequestConfig.config.xmland HowTo section 17.9 still setreadtimeout.HttpSenderModule.getHttpOptionskept copying it into the options, where nothing reads it.sockettimeoutnorconnecttimeoutis set by the shipped configuration, so every send uses the 60 second defaults whateverreadtimeoutsays.The timeouts are also only configurable on the sender module, so giving one slow partner longer means raising it for every partner.
Change
readtimeoutis honoured as the socket timeout whensockettimeoutis not set.sockettimeoutwins when both are set.connecttimeoutandsockettimeoutattributes, in milliseconds:HttpSenderModule.getHttpOptions(Partnership), used by bothAS2SenderModuleandMDNSenderModule. It follows how the mutual TLS client certificate settings are already taken from the partnership.Behaviour change to be aware of: the sample
openas2.propertiessetsmodule.AS2SenderModule.readtimeout=3000000, which is 50 minutes. That value now takes effect for anyone who copied it. The changelog entry points this out. I left the sample alone because the value looks deliberate, but I'm happy to lower it if you prefer.Tests
SendTimeoutTest:readtimeoutused as the socket timeout;sockettimeoutwinning overreadtimeout;AS2SenderModule.handleto a local partner that takes 3 seconds to answer. A 400ms partnership socket timeout ends the send well before the answer. The control, without an override, waits for it.Mutation checks: each of these changes fails a test:
readtimeoutignored againThe
MDNSenderModulecall site is the same one-line change but is not exercised by a test, since that needs an async MDN exchange.Test isolation:
SendTimeoutTestandInterruptedSendReportStartupTestnow setstorageBaseDirto a folder of their own. The test configuration's pending folders (%home%/../data) are shared between test classes, and the pending files left by this test's sends changed what the startup report test could conclude.Full suite: 254 tests pass.
Docs
HowTo section 17.9 gains
sockettimeout,connecttimeout, the per-partnership attribute, and async MDN as an alternative for partners that are slow to respond. The PDF is regenerated; compared with an export of the unchanged document from the same LibreOffice, the only text added is those paragraphs (a table's repeated header row moves with the page break).