问题描述
我有以下使用IO(Tcp)
的Actor的示例
I have the following example of Actor using IO(Tcp)https://gist.github.com/flirtomania/a36c50bd5989efb69a5f
为了进行实验,我将其运行了两次,因此它试图绑定到803端口。显然我犯了一个错误。
For the sake of experiment I've run it twice, so it was trying to bind to 803 port. Obviously I've got an error.
问题:如何获得 CommandFailed的原因?在application.conf中,我启用了slf4j并调试了日志级别,然后我的日志中出现了错误。
Question: How can I get the reason why "CommandFailed"? In application.conf I have enabled slf4j and debug level of logs, then I've got an error in my logs.
DEBUG akka.io .TcpListener-端点[localhost / 127.0.0.1:803]上的TCP通道绑定失败:java.net.BindException:地址已在使用中:bind
但是为什么只有调试级别呢?我不想让所有ActorSystem都记录他们的事件,我想知道CommandFailed事件的原因(例如java.lang.Exception实例,我可以使它成为 e.printStackTrace()
)
But why is that only debug level? I do not want to enable all ActorSystem to log their events, I want to get the reason of CommandFailed event (like java.lang.Exception instance which I could make e.printStackTrace()
)
类似于:
case c @ CommandFailed => val e:Exception = c.getReason()
也许不是Akka方式吗?然后如何获取诊断信息?
Maybe it's not the Akka-way? How to get diagnostic info then?
推荐答案
您可以执行以下操作-找到仍然存在的PID,然后将其杀死。
Here's what you can do - find the PID that still keeps living and then kill it.
在Mac上-
lsof -i:portNumber
然后
kill- 9 PidNumber
lsof -i : portNumberthen kill -9 PidNumber
这篇关于Akka IO(Tcp)获取CommandFailed的原因的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!