Connect logger not logging remote address under Node 0.10 when Connection: Close header set #811

ruoho opened this Issue May 17, 2013 · 2 comments


None yet
3 participants

ruoho commented May 17, 2013

The Connect logger middleware does not log the client :remote-addr correctly under Node 0.10.6 when the Connection: Close header is set on a client request. This is logged correctly with Node 0.8.23. Sample code:

var connect = require('connect');

var app = connect()
  .use(function(req, res){
    res.end('hello world\n');

Make two requests to the server:

$ perl -e 'print "GET /request1 HTTP/1.1\r\nHost: localhost\r\n\r\n"' | nc localhost 3000
$ perl -e 'print "GET /request2 HTTP/1.1\r\nConnection: close\r\nHost: localhost\r\n\r\n"' | nc localhost 3000

The output from connect.logger shows the following from these requests: - - [Fri, 17 May 2013 17:31:57 GMT] "GET /request1 HTTP/1.1" 200 - "-" "-"
- - - [Fri, 17 May 2013 17:31:47 GMT] "GET /request2 HTTP/1.1" 200 - "-" "-"

In the request with the client Connection: close header set, the client's address (:remote-addr from the default logger format) is not displayed.


jonathanong commented Oct 12, 2013

hi, can you add a test?


dougwilson commented Oct 17, 2013

The only solution is to get the remote address from the socket before the socket is closed. At the time the logger is invoked to format the line, it is too late.

jonathanong closed this in #930 Oct 17, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment