akka/akka-core

UdpListener crashes when sending a message fails

Open

#19,771 opened on Feb 13, 2016

View on GitHub
 (5 comments) (0 reactions) (0 assignees)Scala (13,277 stars) (3,547 forks)batch import
1 - triagedhelp wantedt:dnst:io

Description

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.

Contributor guide

UdpListener crashes when sending a message fails · akka/akka-core#19771 | Good First Issue