diff --git a/acceptor.go b/acceptor.go index da4cd9bb0..f5b9b281c 100644 --- a/acceptor.go +++ b/acceptor.go @@ -356,7 +356,7 @@ func (a *Acceptor) handleConnection(netConn net.Conn) { go func() { msgIn <- fixIn{msgBytes, parser.lastRead} - readLoop(parser, msgIn) + readLoop(parser, msgIn, a.globalLog) }() writeLoop(netConn, msgOut, a.globalLog) diff --git a/connection.go b/connection.go index c006560f4..99a4c465e 100644 --- a/connection.go +++ b/connection.go @@ -30,12 +30,13 @@ func writeLoop(connection io.Writer, messageOut chan []byte, log Log) { } } -func readLoop(parser *parser, msgIn chan fixIn) { +func readLoop(parser *parser, msgIn chan fixIn, log Log) { defer close(msgIn) for { msg, err := parser.ReadMessage() if err != nil { + log.OnEvent(err.Error()) return } msgIn <- fixIn{msg, parser.lastRead} diff --git a/connection_internal_test.go b/connection_internal_test.go index 1ee4d13e8..081b3c110 100644 --- a/connection_internal_test.go +++ b/connection_internal_test.go @@ -45,7 +45,7 @@ func TestReadLoop(t *testing.T) { stream := "hello8=FIX.4.09=5blah10=103garbage8=FIX.4.09=4foo10=103" parser := newParser(strings.NewReader(stream)) - go readLoop(parser, msgIn) + go readLoop(parser, msgIn, nullLog{}) var tests = []struct { expectedMsg string diff --git a/initiator.go b/initiator.go index eeff30fc0..8f7a76200 100644 --- a/initiator.go +++ b/initiator.go @@ -198,7 +198,7 @@ func (i *Initiator) handleConnection(session *session, tlsConfig *tls.Config, di goto reconnect } - go readLoop(newParser(bufio.NewReader(netConn)), msgIn) + go readLoop(newParser(bufio.NewReader(netConn)), msgIn, session.log) disconnected = make(chan interface{}) go func() { writeLoop(netConn, msgOut, session.log)