Skip to content

Commit

Permalink
Increasing the connections timeout... and much less failed requests.
Browse files Browse the repository at this point in the history
  • Loading branch information
jponge committed Feb 24, 2012
1 parent fd04e03 commit 0a3c31e
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import com.twitter.util.Future
import scala.util.matching.Regex
import org.joda.time.DateTime
import com.twitter.finagle.http.{Response, Request, RichHttp, Http}
import com.twitter.conversions.time._

/**
* A HTTP Proxy server based on Twitter Finagle that detects common search
Expand All @@ -30,6 +31,7 @@ object SearchEngineHttpProxy {

service(request) handle {
case error =>
println("Could not serve a request: " + error)
val statusCode = error match {
case _: IllegalArgumentException => FORBIDDEN
case _ => INTERNAL_SERVER_ERROR
Expand Down Expand Up @@ -60,6 +62,8 @@ object SearchEngineHttpProxy {
val client = ClientBuilder()
.codec(Http())
.hosts(target)
.timeout(30.seconds)
.tcpConnectTimeout(30.seconds)
.hostConnectionLimit(1)
.build()

Expand Down Expand Up @@ -223,6 +227,8 @@ object SearchEngineHttpProxy {
.codec(RichHttp[Request](Http()))
.bindTo(new InetSocketAddress(8080))
.name("proxy")
.readTimeout(30.seconds)
.requestTimeout(30.seconds)
.build(myService)
}
}

0 comments on commit 0a3c31e

Please sign in to comment.