You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
I'm using a spray-client to hit another server request. From front-end it is reactjs. I am able to abort a request from reactJS. And it shows in the network tab of browser console that the request is canceled. On every key-stroke, I'm calling an API if I get the next key-stroke and don't get a response from the previous key-stroke then I abort(using AbortController()) I'm canceling the previous request and so on.
So in this, I'm hitting spray API which internally hits another server using spray-client. So I'm getting a response after exactly 22 seconds on the last key-stroke.
This is the configuration I'm using for spray:
pathPrefix("complete") {
post {
entity(as[CompleteRequest]) { CompleteRequest => ctx =>
val uNameAccountId = user.username.get + "|" + account.id.get
(sActor ? JwtToken(uNameAccountId)).mapTo[Either[Rejection,String]].map {
case Left(e) => ctx.reject(e)
case Right(token) => {
jwt_token = token
var list2: Seq[String] = Seq()
(sActor ? GetUserData(account, user)).mapTo[Either[Rejection, UserData]] map {
case Left(userData) => Future.failed(new Exception())
case Right(userData) => {
.
.
.
requestBody = JsonFormat.toJsonString(requestObj)
(sActor ? CompleteReq(sessionId.substring(0, 31), jwt_token, requestBody)).mapTo[Either[Rejection, ByteString]] map {
case Left(error) => ctx.reject(error)
case Right(response) => ctx.complete(response)
}
}
}
}
}
}
}
}
case m: CompleteReq => {
val start1 = System.currentTimeMillis()
val actorSender = sender()
val result = completeService(m.session,m.jwttoken,m.completeRequest)
result.onComplete {
case Success(response) => actorSender ! Right(response)
case Failure(error) => actorSender ! Left(DarkroomVaErrorRejection(new Exception("not able to fetch data from DB",error),Some("not able to fetch data from DB")))
}
}
def completeService(session: String, jwttoken: String, completeRequest: String): Future[HttpResponse] = {
val pipeline: HttpRequest => Future[HttpResponse] = sendReceive ~> unmarshal[HttpResponse]
val response: Future[HttpResponse] = pipeline(Post(remoteUrl, completeRequest)
response
}
As shown in image last request is taking time to hit api(i.e. complete api). After complete api is hitted it gives response in millisecond. But somehow that last request is consuming time somewhere to hit api(i.e. "complete" api)
The text was updated successfully, but these errors were encountered:
Sign up for freeto subscribe to this conversation on GitHub.
Already have an account?
Sign in.
I'm using a spray-client to hit another server request. From front-end it is reactjs. I am able to abort a request from reactJS. And it shows in the network tab of browser console that the request is canceled. On every key-stroke, I'm calling an API if I get the next key-stroke and don't get a response from the previous key-stroke then I abort(using AbortController()) I'm canceling the previous request and so on.
So in this, I'm hitting spray API which internally hits another server using spray-client. So I'm getting a response after exactly 22 seconds on the last key-stroke.
This is the configuration I'm using for spray:
Here is the code. That i' m doing:
As shown in image last request is taking time to hit api(i.e. complete api). After complete api is hitted it gives response in millisecond. But somehow that last request is consuming time somewhere to hit api(i.e. "complete" api)
The text was updated successfully, but these errors were encountered: