function is always called with the A_protocol as argument, yet sometimes and totally unpredictably as far as I can tell connectionLost is not called on some A_protocol instances and corresponding A connections get stuck in CLOSE_WAIT state. Another hint is that netstat shows 1 byte in the Recv-Q for those connections (and 0 in the Send-Q).