Bilal-S / iis2tomcat

AJP Connector between Internet Information Services (IIS) and Apache Tomcat
http://www.boncode.net/boncode-connector
49 stars 32 forks source link

packet length determination problem #90

Closed suzery2000 closed 4 years ago

suzery2000 commented 4 years ago

Hi, I encounter an issue with receiving a complete response for POST requests where Content-Type: Multipart/Related and response of size ~90MB.
I send the POST messages through Postman, which is configured to accept unlimited response size. The Postman settings When sending the request directly to the Tomcat server (and not going through IIS and BonCode AJP), the correct size of response is returned. However, when sending the request through IIS and BonCode, only part of the response is returned. The size of the response varies from 10MB to 40MB for the same POST message. In the BonCode log file, the number of bytes in the BonCodeAJP13.TomcatPackets.TomcatSendBodyChunk entries sum up correctly to ~90MB. However, the IIS log file shows a lower size of response. In addition, the following error and exception is logged in the BonCode log file: 2020-03-20 15:13:16 1.0.25 ERROR packet length determination problem Source array was not long enough. Check srcIndex and length, and the array's lower bounds. at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable) at BonCodeAJP13.BonCodeAJP13ServerConnection.GetInt16B(Byte[] Data, Int32 Pos) at BonCodeAJP13.BonCodeAJP13ServerConnection.AnalyzePackage(Boolean& delayWriteIndicator, Byte[] receiveBuffer, Boolean skipFlush, Int32 iOffset). Appreciate your advice on how to solve this issue.

Bilal-S commented 4 years ago

Have you changed the IIS file upload restrictions? E.g. https://hoststud.com/resources/how-to-increase-the-maximum-upload-file-size-in-iis.422/

suzery2000 commented 4 years ago

Hi @Bilal-S , changing the upload restrictions does not completely solve the issue. It seems like now there are more POST responses of the right size (~94MB), but still some of them return a lower response size. IIS always returns a 200 status response whether it is a complete or pratial response.

Bilal-S commented 4 years ago

Suzery: Without being able to replicate it will be hard for me to find the reason. I will need a little more detail on your setup:

Best, Bilal

suzery2000 commented 4 years ago
  • What version of Tomcat / IIS Tomcat 7.0.37 IIS 8.5

  • What application services are you using: JSP, servlets, cfmls? Servlets

  • How did you install / create the initial system configuration? Standard installation, no special configurations

  • What if any changes did you make to BonCode settings? AJP settings on Tomcat? BonCodeAJP13.settings:
    FlushThresholdTicks: 60000 FlushThreshold: 0 PacketSize: 65530

suzery2000 commented 4 years ago

Hi @Bilal-S , there are also warnings written to Event Viewer Exception information: Exception type: HttpException Exception message: Server cannot set status after HTTP headers have been sent. at System.Web.HttpResponse.set_StatusCode(Int32 value) at BonCodeIIS.BonCodeCallHandler.PrintError(HttpContext context, String strPublicErr, String strLocalErr) at BonCodeIIS.BonCodeCallHandler.ProcessRequest(HttpContext context) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

suzery2000 commented 4 years ago

Hi @Bilal-S , the attached debug traces from WinDbg show that the AJP connector throws an exception, which leads to an HTTP error. It seems that the the exception in the AJP connector causes the issue of not receiving the complete POST response. Appreciate if you can look into it.

debug.log

Bilal-S commented 4 years ago

The error you noticed seems to come from making a 16 bit request to get high and low bites for packet size determination. This should normally not fail unless something on transport layer was miread or garbled. What type of content is in 90MB files (data, video?)

Can you try to alternate your flush values? This is sometimes an area were things can get garbled: a) Remove all flushes b) use FlushThresholdBytes in 5MB blocks (5242880) instead of FlushThresholdTicks: 60000

suzery2000 commented 4 years ago

This indeed solves the issue. Thank you for your support. The content of the 90MB are image frames. The Tomcat server hosts several servlets, some of them serve image acquisition requests, other servlets serve data requests.

Bilal-S commented 4 years ago

Glad we were able to resolve this for you. Best, B.