Skip to content

Akka.IO & WSAEWOULDBLOCK socket error #3188

@andreichuk

Description

@andreichuk

Akka.NET version 1.3.2
Windows 10

Akka.IO does not handle non-fatal socket errors like WSAEWOULDBLOCK (System.Net.Sockets.SocketError.WouldBlock) which lead to closing of a connection.
From MSDN: Resource temporarily unavailable. This error is returned from operations on nonblocking sockets that cannot be completed immediately, for example recv when no data is queued to be read from the socket. It is a nonfatal error, and the operation should be retried later.

When I'm trying to send a large (1 Mb or more) amount of data over the wire, I split it in chunks ~64kb and send one by one:

  1. Get a chunk of data (if anything left)
  2. Send it to Akka.IO
  3. Receive an acknowledgement
  4. Go to 1.
    With default Akka.IO tcp settings sending a file from a client to a server (both localhost) usually fails after few cycles because a socket throws WSAEWOULDBLOCK socket exception. It looks like the acknowledgement is sent by Akka.IO when data has been added to the socket's send buffer, not when it's actually has been sent. So overflowing the send buffer leads to the error. Decreasing chunk size to ~10 Kb helps but there is no guarantee that:
    a) there is only one "chunk sender" on the client at the moment;
    b) the server is able read/process even those 10 Kb fast enough.

I checked this code. It does not catch any exceptions, just checks a number of bytes written. Maybe there should be a catcher for WSAEWOULDBLOCK that waits for N milliseconds and then call the method again? Or you have better ideas? Help is appreciated! :)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions