Problem description: nginx reverse proxy
When using Hessian to implement web services, nginx proxy_pass you must use the http post method to transmit data when creating objects. However, nginx proxy an exception (COM. caucho. hessian. client. hessianconnectionexception: 411: Java. io. ioexception: server returned HTTP response code: 411 for URL: http: // xxxx/XXX/xxxservice ).
First, let's take a look at the explanation of the HTTP 411 error: the length required server cannot process the request unless the customer sends a Content-Length header. (New in HTTP 1.1) This is because Hessian communicates with the server by default and uses chunked encoding to send data. The reverse proxy must obtain the Content-Length header before processing the request,nginx reverse proxy example however, Hessian requests do not include this parameter.
Solution:
In the com. Caucho. Hessian. Client. hessianproxyfactory class, nginx proxy manager there is a Boolean _ chunckedpost Domain Member whose default value is true. This parameter specifies whether Hessian exchanges data with the server through multipart transmission. caucho. hessian. client. after the hessianproxyfactory object (assume it is factory), jwilder nginx proxy you only need to call the setchunckedpost () method on it and set this attribute to false. Factory. setchunkedpost (false );
Multipart encoding transmission:nginx reverse proxy docker
Chunked Encoding transmission is a method defined in HTTP 1.1 for Web users to submit data to the server, when the server receives chunked encoding data, it will allocate a buffer to store it. If the submitted data size is unknown, the client will submit the data to the server with a negotiated block size.
The content can be broken up into a number of chunks; each of which is prefixed by its size in bytes. A zero size chunk indicates the end of the Response Message. if a server is using chunked encoding it must set the transfer-encoding header to "chunked ".
Chunked encoding is useful when a large amount of data is being returned to the client and the total size of the response may not be known until the request has been fully processed. an example of this is generating an HTML table of results from a database query. if you wanted to use the Content-Length header you wocould have to buffer the whole result set before calculating the total content size. however, with Chunked Encoding you coshould just write the data one row at a time and write a zero sized chunk when the end of the query was reached.
If the chunked encoding transmission mode is not used, you need to cache the data to be sent and calculate the Content-Length to meet the requirements of the reverse proxy (nginx) for Content-Length.