Akka+scala反向服务器错误



我有问题这是我的服务器https://github.com/vladimirkozhaev/reverse-str这是我的客户https://github.com/vladimirkozhaev/string-reverse-client当我用sbt-run命令运行服务器时,然后运行以下测试

包org.reverstr.client

import org.scalatest.concurrent.PatienceConfiguration.Timeout
import org.scalatest.{FunSpecLike, Matchers}
import org.scalatest.concurrent.ScalaFutures
import scala.concurrent.duration._
class RClientIntegrationSpec extends FunSpecLike with Matchers with ScalaFutures {
val client:RClient = new RClient("127.0.0.1:2552")
describe("reverse str Scala Client") {
describe("set method") {
it("should set a value") {
whenReady(client.setStr("123"), Timeout(1 second)) {
r => r shouldBe "321"
}
}
}

}
}

有这个奇怪的错误消息我哪里错了?

〔信息〕〔2017年9月30日22:34:52.985〕〔pool-4-thread-9〕[akka.remote.Remoting]正在启动远程处理[ERROR][09/30/201722:34:53.466][LocalSystem akka.remote.default-remote-dispatcher-13][NettyTransport(akka://LocalSystem)]未能绑定到/127.0.0.1:2552,关闭Netty传输[错误][2017年9月30日22:34:53.516][pool-4-thread-9][akka.remote.Remoting]远程处理错误:[启动失败][akka.remote.RemoteTransportException:启动失败在akka.remote.Remoting.akka$remote$Remoting$$notifyError(Remoting.scala:146)在akka.remote.Remoting.start(Remoting-scala:212)位于akka.remote.RemoteActorRefProvider.init(RemoteActorRefProvider.scala:212)在akka.aactor.ActorSystemImpl.liftedTree2$1(ActorSystem.scala:796)位于akka.aactor.ActorSystemImpl._start$lzycompute(ActorSystem.scala:793)位于akka.aactor.ActorSystemImpl._start(ActorSystem.scala:793)在akka.aactor.ActorSystemImpl.start(ActorSystem.scala:809)在akka.aactor.ActorSystem$.apply(ActorSystem.scala:244)在akka.aactor.ActorSystem$.apply(ActorSystem.scala:287)在akka.aactor.ActorSystem$.apply(ActorSystem.scala:232)网址:org.reversestr.client.RClient.(RClient.scala:11)网址:org.reversestr.client.RClientIntegrationSpec.(RClientIntegrationSpec.scala:9)在sun.reflect.NativeConstructorAccessorImpl.newInstance0(本机方法)在sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessor Impl.java:62)在sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessor Impl.java:45)位于java.lang.reflect.Constructure.newInstance(Constructor.java:423)位于java.lang.Class.newInstance(Class.java:442)网址:org.scalatest.tools.Framework$ScalaTestTask.execute(Framework.scala:646)在sbt。TestRunner.runTest$1(TestFramework.scala:76)在sbt。TestRunner.run(TestFramework.scala:85)在sbt。TestFramework$$anon$2$$anonfun$$init$$1$$anonfon$apply$8.apply(TestFramework.scala:202)在sbt。TestFramework$$anon$2$$anonfun$$init$$1$$anonfon$apply$8.apply(TestFramework.scala:202)在sbt。TestFramework$.sbt$TestFramework$$withContextLoader(TestFramework.scala:185)在sbt。TestFramework$$anon$2$$anonfun$$init$$1.apply(TestFramework.scala:202)在sbt。TestFramework$$anon$2$$anonfun$$init$$1.apply(TestFramework.scala:202)在sbt。TestFunction.apply(TestFramework.scala:207)在sbt。测试$$anonfun$9.apply(Tests.scala:216)在sbt。测试$$anonfun$9.apply(Tests.scala:216)在sbt.std.Transform$$anon$3$$anonfun$apply$2.apply(System.scala:44)在sbt.std.Transform$$anon$3$$anonfun$apply$2.apply(System.scala:44)在sbt.std.Transform$$anon$4.work(System.scala:63)在sbt。执行$$anonfun$submit$$anonfon$apply$1.apply(执行.scala:226)在sbt。执行$$anonfun$submit$$anonfon$apply$1.apply(执行.scala:226)在sbt。ErrorHandling$.widConvert(ErrorHandling.scala:17)在sbt。Execute.work(Execute.scala:235)在sbt。执行$$anonfun$submit$1.apply(执行.scala:226)在sbt。执行$$anonfun$submit$1.apply(执行.scala:226)在sbt。并发限制$$anon$4$$anonfun$1.apply(并发限制.scala:159)在sbt。CompletionService$$anon$2.call(CompletionServices.scala:28)位于java.util.concurrent.FFutureTask.run(FutureTask.java:266)位于java.util.concurrent.Executors$RunnableAdapter.call(Executitors.java:511)位于java.util.concurrent.FFutureTask.run(FutureTask.java:266)位于java.util.concurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1142)位于java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)在java.lang.Thread.run(Thread.java:745)由以下原因引起:org.jbos.netty.channel.ChannelException:未能绑定到:/127.0.0.1:2552网址:org.jboss.nety.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:272)在akka.remote.transport.nety.NettyTransport$$anonfun$listen$1.apply(NettyTransport.scala:417)在akka.remote.transport.nety.NettyTransport$$anonfun$listen$1.apply(NettyTransport.scala:413)在scala.util.Success$$anonfun$map$1.apply(Try.scala:236)在scala.util.Try$.apply(Try.scala:191)位于scala.util.Success.map(Try.scala:236)在scala.concurrent.FFuture$$anonfun$map$1.apply(Future.scala:235)在scala.concurrent.FFuture$$anonfun$map$1.apply(Future.scala:235)在scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)位于akka.dispatch.BatchingExecutor$AbstractBatch.processBatch(BatchingExecutor.scala:55)在akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply$mcV$sp(BatchingExecutor.scala:91)在akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)在akka.dispatch.BatchingExecutor$BlockableBatch$$anonfun$run$1.apply(BatchingExecutor.scala:91)在scala.concurrent.BlockContext$.withBlockContext(BlockContext.scala:72)在akka.dispatch.BatchingExecutor$BlockableBatch.run(BatchingExecutor.scala:90)位于akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:40)在akka.dispatch.FukJoinExecutiutoConfigurator$AkkaForkJoinTask.exec(ForkJoinExecutiutoConfigurationr.scala:43)在akka.dispatch.fukjoin.FukJoinTask.doExec(ForkJoinTask.java:260)在akka.dispatch.fukjoin.FukJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339)在akka.dispatch.fukjoin.FukJoinPool.runWorker(ForkJoinPool.java:1979)位于akka.dispatch.forkjoin.FukJoinWorkerThread.run(ForkJoinWorker线程.java:107)由:java.net.BindException引起:地址已在使用:bind位于sun.nio.ch.Net.bind0(本机方法)位于sun.nio.ch.Net.bind(Net.java:433)位于sun.nio.ch.Net.bind(Net.java:425)位于sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChanelImpl.java:223)位于sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdapter.java:74)网址:org.jboss.nety.channel.socket.nio.NioServerBoss$RegisterTask.run(NioServerBoss.java:193)网址:org.jboss.nety.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:391)网址:org.jboss.nety.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:315)网址:org.jboss.nety.channel.socket.nio.NioServerBoss.run(NioServerBoss.java:42)网址:org.jboss.nety.util.ThreadRenamingRunnable.run(ThreadRenamingRunable.java:108)网址:org.jboss.nety.util.internal.DedLockProofWorker$1.run(DeadLockProofWorker.java:42)位于java.util.concurrent.ThreadPoolExecutiator.runWorker(ThreadPoolExecutiator.java:1142)位于java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)在java.lang.Thread.run(Thread.java:745)

似乎已经有另一个应用程序在指定端口运行:2552。异常清楚地表明:java.net.BindException: Address already in use:

快速解决方案是通过终止在该端口运行的应用程序来清除该端口

要清除端口,请在shell(或终端)中执行以下命令:

kill -9 $(lsof -t -i:2552)

然后,重试运行测试。

命令解释:

  • lsof-t-i:2552返回在端口2552上运行的应用程序的进程id
  • kill-9 process_id杀死具有给定进程id的应用程序

相关内容

最新更新