0

我遇到了从 Play 2.6 应用程序调用 Freshdesk API 的问题,我创建了一个库来使用 Retrofit 和另一个类来使用 Play WS 执行相同操作,但是当我在 Play 应用程序中启动该进程时,每个选项都失败了。

我测试了我的 Retrofit 客户端,创建/删除操作在我的集成测试中运行良好。

这是我使用 Play WS 而不是 Retrofit 客户端的代码。

public void create(String userEmail, String subject, String content) {

    // Obtain configuration using internal class and enumerations
    Config config = appService.getConfiguration(EConfig.FRESHDESK);

    JsonNode request = Json.newObject()
            .put("email", userEmail)
            .put("subject", subject)
            .put("description", content)
            .put("status", 2) // Fixed to "Open"
            .put("priority", 1); // Fixe to "Normal"

    CompletionStage<WSResponse> response = client.url(config.getString("url"))
        .setAuth(config.getString("token"), "X")
        .setContentType("application/json")
        .post(request);

    response.thenApply(wsResponse -> {

        System.out.println(wsResponse);

        return null;
    }).exceptionally(cause -> {

        logger.error("Error calling Freshdesk, this problem cannot be reported.", cause);

        return null;
    });

}

这是 Play WS 调用的堆栈跟踪:

java.util.concurrent.CompletionException: java.net.ConnectException: Received fatal alert: internal_error
  at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292)
  at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308)
  at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:593)
  at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)
  at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
  at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
  at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:21)
  at scala.concurrent.java8.FuturesConvertersImpl$CF.apply(FutureConvertersImpl.scala:18)
  at scala.concurrent.impl.CallbackRunnable.run$$$capture(Promise.scala:60)
  at scala.concurrent.impl.CallbackRunnable.run(Promise.scala)
Caused by: java.net.ConnectException: Received fatal alert: internal_error
  at play.shaded.ahc.org.asynchttpclient.netty.channel.NettyConnectListener.onFailure(NettyConnectListener.java:168)
  at play.shaded.ahc.org.asynchttpclient.netty.channel.NettyConnectListener$1.onFailure(NettyConnectListener.java:139)
  at play.shaded.ahc.org.asynchttpclient.netty.SimpleFutureListener.operationComplete(SimpleFutureListener.java:26)
  at play.shaded.ahc.io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:507)
  at play.shaded.ahc.io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:500)
  at play.shaded.ahc.io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:479)
  at play.shaded.ahc.io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:420)
  at play.shaded.ahc.io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:122)
  at play.shaded.ahc.io.netty.handler.ssl.SslHandler.notifyHandshakeFailure(SslHandler.java:1443)
  at play.shaded.ahc.io.netty.handler.ssl.SslHandler.setHandshakeFailure(SslHandler.java:1435)
Caused by: javax.net.ssl.SSLException: Received fatal alert: internal_error
  at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
  at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1666)
  at sun.security.ssl.SSLEngineImpl.fatal(SSLEngineImpl.java:1634)
  at sun.security.ssl.SSLEngineImpl.recvAlert(SSLEngineImpl.java:1800)
  at sun.security.ssl.SSLEngineImpl.readRecord(SSLEngineImpl.java:1083)
  at sun.security.ssl.SSLEngineImpl.readNetRecord(SSLEngineImpl.java:907)
  at sun.security.ssl.SSLEngineImpl.unwrap(SSLEngineImpl.java:781)
  at javax.net.ssl.SSLEngine.unwrap(SSLEngine.java:624)
  at play.shaded.ahc.io.netty.handler.ssl.SslHandler$SslEngineType$3.unwrap(SslHandler.java:272)
  at play.shaded.ahc.io.netty.handler.ssl.SslHandler.unwrap(SslHandler.java:1175)
4

1 回答 1

0

最后问题是我自己的错误,当我在配置中编写端点 URL 时,我犯了一个拼写错误。

于 2018-10-29T10:01:14.773 回答