I use net.databinder.dispatch to call a web server with 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 defines:
Connection: keep-alive
and the server defines:
Keep-Alive: timeout=120, max=256
If I call the webserver consecutively many times (but not in parallel), I get an error:
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 c.n.h.c.p.n.NettyAsyncHttpProvider - 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 happen with other web servers that close the connection.
What is the problem here? The webserver? The client?
Is net.databinder.dispatch really using the keep-alive feature (so, reusing the same socket), or creating a new one each time? How do I modify the previous example to tell net.databinder.dispatch to use the keep-alive feature?
the version that i am using:
<dependency>
<groupId>net.databinder.dispatch</groupId>
<artifactId>dispatch-core_2.10</artifactId>
<version>0.9.5</version>
</dependency>