akka/akka-core

UdpListener crashes when sending a message fails

オープン

#19,771 opened on 2016/02/13

 (5 件のコメント) (0 件のリアクション) (0 人の担当者)Scala (3,547 件のフォーク)batch import
1 - triagedhelp wantedt:dnst:io

Repository metrics

Stars
 (13,277 個のスター)
PR merge metrics
 (平均マージ 8d 19h) (30d で 10 merged PRs)

説明

Currently akka.io.UdpListener seems to crash if one tries to send a packet to an unreachable target address (interesting: There is a mechanism to reply CommandFailed when NonFatal exceptions happen during a sent, but it only kicks in if the target address had to be resolved by Dns.resolve).

The following happens when I try to Udp.Send against an address that is unreachable from the address of the bound socket.

19:57:44.236 [DEBUG] [akka://IceAgentSpec/system/IO-UDP-FF/selectors/$a/0] akka.io.SelectionHandler - Network is unreachable
19:57:44.238 [DEBUG] [akka://IceAgentSpec/system/IO-UDP-FF/selectors/$a/0] akka.io.UdpListener - Closing DatagramChannel after being stopped

From a user perspective I'd rather expect to receive a Udp.CommandFailed message as a reply to my Udp.Send rather than a shutdown of the whole UdpListener.

There could be several reasons why a packet could not be sent:

  • SocketException("Network is unreachable") - this does currently crash the actor
  • SocketException("Invalid argument") - happens if we try to send to the target port 0, but probably could have other reasons. This does currently crash the actor
  • Target hostname could not be resolved - this case is currently ignored. The actor stays alive but the user does receive no CommandFailed or Ack.
  • Probably a lot more, maybe even something like SocketException("already closed") - I guess we would expect a listener shutdown in this case?

This is somewhat related to #13861 becase a fix of this issue would make a plain CommandFailed even harder to interpret from a user perspective.

コントリビューターガイド