Net.databinder.dispatch does not work with too many keep-alive connections

I use net.databinder.dispatch to invoke a web server using this:

import dispatch._ def request(in: String, address: java.net.URI, headers: Map[String, String]): String = { val req = url(address.toString) << in <:< headers val s = Http(req OK as.String) s() } 

the client determines:

 Connection: keep-alive 

and the server determines:

 Keep-Alive: timeout=120, max=256 

If I call the web server sequentially many times (but not in parallel), I get an error message:

 Exception in thread "main" java.util.concurrent.ExecutionException: dispatch.StatusCode: Unexpected response status: 500 at com.ning.http.client.providers.netty.NettyResponseFuture.abort(NettyResponseFuture.java:297) 19:32:46.474 [New I/O worker #10] DEBUG cnhcpnNettyAsyncHttpProvider - Unexpected response status: 500 at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.abort(NettyAsyncHttpProvider.java:1326) dispatch.StatusCode: Unexpected response status: 500 at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.access$700(NettyAsyncHttpProvider.java:137) 

This error does not occur with other web servers that close the connection.

What is the problem? Web server? Customer?

Does net.databinder.dispatch really use the keep-alive function (like reusing the same socket) or creating a new one each time? How to modify the previous example to tell net.databinder.dispatch to use the keep-alive function?

version i am using:

 <dependency> <groupId>net.databinder.dispatch</groupId> <artifactId>dispatch-core_2.10</artifactId> <version>0.9.5</version> </dependency> 
+4
source share

All Articles