Comments (11)
Well, the error is clearly on the sender side.
If they claim to use "chunked encoding" they need to follow the specification.
Outcommenting these lines means handling the messages as a "non-chunked" (hence a "regular") transmission.
With this commenting, you will not be able to received chunked encoding messages from any sender that is using it correctly.
from as2-lib.
This is an example of the file I'm using as a test if you need something to try out with. I further tested with some variations of file contents and it seems like the first line of the file is causing the problem, even something as simple as "12345" will result in the offset error. Without the first line in the above-attached text file, it seems like the AS2 message can be received successfully even with chunked encoding enabled for messages less than 10KB. For messages more than 10KB, although there wasn't any error triggered, the received file will become empty.
The combination I tried that consistently gets the error is when chunked encoding is enabled, the file size is greater than 10KB and the first line of the text file contains 5 characters or more.
from as2-lib.
Hi, unfortunately I cannot find the exact source of the exception.
Instead I am pointing you to the source of HTTP chunked encoding: RFC 7230, section 4.1: https://datatracker.ietf.org/doc/html/rfc7230#section-4.1
According to the spec, each chunked block needs to start with the length of the block. This is missing in your example payload.
Correct input looks e.g. like this:
2
ab
1
c
0
from as2-lib.
Thanks for your response, it seems to be working for me now after commenting out lines 236 to 240 in HTTPHelper.java, importing the Apache Common IO library, and adding this line of code below the commented lines:
aBytePayload = IOUtils.toByteArray(aIS);
It seems like the input stream at this point in time already has the complete message and all I had to do is convert it to a byte array and pass it through to the rest of the functions. Do you know if there would be any implication in changing the codes this way?
from as2-lib.
P.S. somebody wrote an article on that: "BizTalk AS2 and Chunked Encoding (Disable it!)"
https://jason.agostoni.net/2010/09/01/biztalk-as2-and-chunked-encoding-disable-it/
from as2-lib.
That's rather unexpected from a Microsoft product but I guess it's not the only middleware that behaves like this, ArcESB as well. Do you think it's possible to add a check if the decoding of a chunked message fails, you failover to use the input stream as a regular transmission?
from as2-lib.
Nope, that won't work. Because if chunked encoding reading fails in the middle, then the previous parts of the InputStream have already been consumed. The only potential way would be to always store the data in a temporary file and read from there. But that would lead to severe performance degradations etc.
from as2-lib.
Seems like I misjudged Biztalk, I installed Wireshark on the server my Biztalk was installed in to monitor the traffic being sent to the JAVA app and noticed that the request is indeed chunked:
I went on to look at the filter chains while in debug mode, I noticed that during the preprocessing of the request at Http11Processor, it encapsulated ChunkedInputFilter to the stream and that might be the culprit doing the parsing of the chunked data when the input stream is being read hence I'm able to transform it into the byte array and use it like that.
Not sure if anyone else's instance of the library behaves like this, I tested with my own JAVA app utilizing the as2-servlet library as well as the as2-demo-webapp from the repository and both resulted in the same behavior. I'm running these JAVA apps using Tomcat so this might be something specific to that.
from as2-lib.
Okay, I will look at it again - thanks for the deep-dive :)
from as2-lib.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from as2-lib.
Version 5.1.1 contains a fixed for chunked encoding issue
from as2-lib.
Related Issues (20)
- Performance issues in AS2 servlet when transferring files HOT 2
- unable to send file to AS2 server from AS2-LIB HOT 5
- getting started HOT 9
- Can AS2DirectoryPollingModule run with as2-lib-spring-demo HOT 7
- Disposition isn't correct when using servlet HOT 14
- "Invalid HTTP Request" Error with Servlet-based Demo-Web-App HOT 8
- java.lang.IllegalStateException: unable to create shared stream: java.io.FileNotFoundException: /tmp/as2-lib-res-16551011638687829143.tmp (No such file or directory) HOT 7
- Spring boot: possible to make custom handler a spring managed bean? HOT 3
- partnership attribute: remove_cms_algorithm_protection_attrib HOT 2
- MIC calculation on outgoing AS2 is incorrect when using compress before signing HOT 9
- Question : Does AS2 includes standard HTTP headers and custom generated headers for communication between 2 systems interacting using AS2 protocol. HOT 1
- Cant' send files to distant client using "MainSendToMendelsonTestServer.java" HOT 2
- Trying to use RSASSA_PKCS1_V1_5_WITH_SHA3_256 signing alg results in IllegalArgumentException: Unknown signature type requested: RSASSAPSS HOT 13
- latest certificates from keystore is not fetching when service is running HOT 2
- Advice on creating documentation HOT 7
- Can't work with AS2 version 5.0 with bc-fips HOT 4
- NoClassDefFoundError: javax/mail/internet/MimeBodyPart HOT 2
- Private Key is Null for public key HOT 4
- bcMail temporary files not deleted when compression is used (as2-lib 5.1.2)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from as2-lib.