func (srv *Service) negotiateClientConn(mux frames.ChannelDialer, clientConn net.Conn) { srv.log.Printf("Dialing new muxed connection for client %v", clientConn.RemoteAddr()) muxedConn, err := mux.Dial() if err == frames.ChannelsExhausted { srv.log.Printf("Ran out of channels when accepting new client connection from %v", clientConn.RemoteAddr()) clientConn.Close() } else if err != nil { srv.log.Printf("Error with manager connection when accepting new client connection from %v: %v", clientConn.RemoteAddr(), err) srv.badMuxConn <- mux clientConn.Close() } else { // Start multiplexing the connection into mux. // TODO: Attempt to add deadlining when sending to the client. srv.manager.HandleNewConnection(muxedConn, clientConn) srv.log.Printf("Artemis client %v handed to connection manager", clientConn.RemoteAddr()) } }