Tag Archives: hessian http response code:411

hessian http response code:411 [How to Solve]

Record a question about Hessian that I met a long time ago

in the process of implementing web service with Hessian, the HTTP post method is used to transfer data when creating objects. However, in the case of nginx, an exception (com.caucho.hessian.client.hessianconnectionexception: 411: java.io.ioexception: server returned HTTP response code: 411 for URL: http://xxxx/xxx/xxxService ) 。

first of all, let’s look at the HTTP 411 error explanation: the length required server cannot process the request unless the client sends a content length header( HTTP 1.1 new) this is because Hessian sends data in chunked encoding by default when communicating with the server, and the reverse proxy can only process the request by obtaining the content length header, but this parameter is not added to Hessian’s request<

we use spring + Hessian for service:
when Hessian’s own factory generates objects:

in com.caucho.hessian.client.HessianProxyFactory, ChunkedPost defaulted true
    private boolean _isChunkedPost = true;
The parameters for exchanging data with the server are sent in chunks, but for the time being nginx does not support

spring’s proxyfactorybean object has a setchunkedpost method, so we can set chunkedpost to false when configuring beans, so as to realize communication through nginx

<bean id="xxx" class="org.springframework.remoting.caucho.HessianProxyFactoryBean">
        <property name="serviceUrl" value=""/>
        <property name="serviceInterface" value=""/>
    	<property name="chunkedPost" value="false"/>
    </bean>