[WSClient] The promise never completes

scala
play-1

(Chenyangqing2017) #1

What should happen is that the promise compeltes with a success or failure. In fact, the promise never completes even if timeout is set.

    wsClient.url(s"$dliEndPoint/v2.0/$serviceProjectID/sessions/$sessionId/statements/$statementId")
      .withHttpHeaders("x-auth-token" -> serviceToken)
      .get()
      .map { res =>
        if (res.status == OK) {
          val state = (Json.parse(res.body) \ "state").as[String]
          if (state == "error" || state == "cancelling" || state == "cancelled") {
            (true, false, s"${res.status} ${res.statusText}, ${res.body}")
          } else if (state == "available") {
            val outputStatus = (Json.parse(res.body) \ "output" \ "status").as[String]
            if (outputStatus == "error") {
              (true, false, s"${res.status} ${res.statusText}, ${res.body}")
            } else if (outputStatus == "ok") {
              (true, true, (Json.parse(res.body) \ "output" \ "data" \ "text/plain").as[String])
            } else {
              (false, false, "")
            }
          } else {
            (false, false, "")
          }
        } else if (res.status /10 == 40) {
          (true, false, s"${res.status} ${res.statusText}, ${res.body}")
        } else {
          throw new ServiceException(ServiceExceptionType.DLI_GET_STATEMENT_ERROR,
            s"get dli statement failed, status is ${res.status} ${res.statusText}, ${res.body}")
        }
      }