0

I have a server that hosts many services. In a scala application, I need to query one of its services : service1/api/endpoint1 The problem I'm facing, is that Http.client.newService expects a host with a port, so in my case

val client: Service[Request, Response] = Http.client
    .withRetryBudget(budget)
    .withMaxResponseSize(StorageUnit.fromMegabytes(1900))
    .withRetryBackoff(Backoff.const(10.seconds))
    .newService("myHost:9999") 

When posting a request

 val req = RequestBuilder
        .post("/service/api/endpoint1")
        .body(jsonReq)
        .request
  val request: Future[Response] = client(req)
  val response = Await.result[Response](request, Duration.fromMinutes(4))

I got the error

An existing connection was forcibly closed by the remote host at remote address myhost:9999

because myhost:9999 doesn't allow direct connections, one can only connect to one of it's services, myhost:9999/service1 or so..

Is there a way to achieve this ? i.e to create the httpclient with the whole url myHost:9999/service1 ?

Crovish
  • 183
  • 10

0 Answers0