I´m having a very bizzare behaviour with Twitter finagle client/server.
Having a Server
def start(): Unit = {
val port=8500
println(s"Running Finagle Mock Server in port $port.......")
mockServer = Some(Http.server
.configuredParams(finagle.Http.Http2)
.configured(finagle.Http.Netty4Impl)
.serve(s"localhost:$port", mockService))
}
And a client
override def client():Unit = {
val clientService = Http.newService("localhost:8500")
val future: Future[Response] = clientService(createRequestUsingBuilderWithJson())
future.onFailure(th =>{
println(th)
})
future.onSuccess(value => {
println(value)
})
val response: Response = Await.result(future)
println(response.contentString)
}
@throws[Exception]
def createRequestUsingBuilderWithJson(): Request = {
new RichHttpRequestBuilder()
.withMethod(Method.Get).withPath("/rest_connection/external_service").build
}
If I run the server as an App in another JVM process and then I run the client everything is fine, I can reach the server and a 200 response is received.
But if instead of run first in another process the server I run in the samr JVM before run ther client the communication never reach the server and I just receive in my onFailure client callback
DefaultHttpResponse(chunked: false)
HTTP/1.1 500 Internal Server Error
content-length: 0
Connection: close
Any idea why I cannot run client/server in the same JVM???