ENETDOWN from nw_connection_t in Transparent Proxy extension

I have a transparenty proxy extension, which proxies outgoing TCP connections to an upstream server. In certain circumstances, I'm getting back an error 50 (ENETDOWN) for what appears to be an orderly shutdown of the server nw_connection_t.

The basic flow is:

  1. Client sends orderly shutdown.
  2. Proxy forwards orderly shutdown to server.
  3. Server disconnects with its own orderly shutdown.
  4. The nw_connection_state_changed_handler is invoked with nw_connection_state_failed / ENETDOWN.

My proxy is serializing all of its handlers on a single queue.

I'm trying to determine if this is the expected behavior, or if there's something I should be doing differently.

You have the following:

com.test.extension  mylogging   FLOW TRACE: read 0 byte(s) from client
com.apple.network   connection  nw_socket_handle_socket_event [C43.1:1] Socket received WRITE_CLOSE event

Which is your acknowledgment of EOF it looks like. From here, do you know how the actual client is closing the TCP connection? Do you know if the client is using close() or something else like shutdown()? The reason I ask is because I seen some irregular behavior awhile back when shutdown() was used on the client to close the connection instead of close(). Is there a large gap of time between WRITE_CLOSE and kNWErrorDomainPOSIX error 50? This was the other characteristic of this issue.

Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
ENETDOWN from nw_connection_t in Transparent Proxy extension
 
 
Q