使用allBoxes
java.nio.channels.ClosedChannelException
网址的调用失败
val allBoxes = "https://www.streak.com/api/v1/boxes"
object Streak {
lazy val builder = new com.ning.http.client.AsyncHttpClientConfig.Builder()
lazy val client = new NingWSClient(builder.build())
def allBoxes = {
client.url(URLS.allBoxes)
.withAuth(Constants.STREAK_API_KEY, "hello", WSAuthScheme.BASIC)
.get
}
}
播放行动
def boxes = Action.async { request =>
Streak.allBoxes.map { response => {
Ok(s"${response.body}")
}}.recover { case th => Ok(s"failed due to ${th.printStackTrace()}")}
}
路由
GET / boxes controllers.Application.boxes()
调用
http://localhost:9000/boxes
完成错误
java.net.ConnectException:https://www.streak.com:443 在com.ning.http.client.providers.netty.request.NettyConnectListener.onFutureFailure(NettyConnectListener.java:128) 在com.ning.http.client.providers.netty.request.NettyConnectListener.access $ 200(NettyConnectListener.java:37) at com.ning.http.client.providers.netty.request.NettyConnectListener $ 1.operationComplete(NettyConnectListener.java:101) 在org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:409) 在org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:395) 在org.jboss.netty.channel.DefaultChannelFuture.setFailure(DefaultChannelFuture.java:362) 在org.jboss.netty.handler.ssl.SslHandler.channelDisconnected(SslHandler.java:575) 在org.jboss.netty.channel.SimpleChannelUpstreamHandler.handleUpstream(SimpleChannelUpstreamHandler.java:102) 在org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:564) 在org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:559) 在org.jboss.netty.channel.Channels.fireChannelDisconnected(Channels.java:396) 在org.jboss.netty.channel.socket.nio.AbstractNioWorker.close(AbstractNioWorker.java:360) 在org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:93) 在org.jboss.netty.channel.socket.nio.AbstractNioWorker.process(AbstractNioWorker.java:108) 在org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:337) 在org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:89) 在org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) 在org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:108) 在org.jboss.netty.util.internal.DeadLockProofWorker $ 1.run(DeadLockProofWorker.java:42) 在java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor $ Worker.run(ThreadPoolExecutor.java:617) 在java.lang.Thread.run(Thread.java:745) 引起:java.nio.channels.ClosedChannelException ......还有16个