Skip to content

Instantly share code, notes, and snippets.

@davetapley
Created April 17, 2014 21:28
Show Gist options
  • Save davetapley/11012625 to your computer and use it in GitHub Desktop.
Save davetapley/11012625 to your computer and use it in GitHub Desktop.
Failing to call res.send(200) in an express app
$ ab -n 1000 -c 1000 http://localhost:3000/hang
This is ApacheBench, Version 2.3 <$Revision: 1554214 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking localhost (be patient)
apr_socket_recv: Connection reset by peer (104)
app.get '/hang', (req, res) ->
console.log 'Request ', n
n += 1
# res.send 200
@davetapley
Copy link
Author

So it's pretty clear that without calling res.send we're just left "hanging".
The console.log usually gets through a few 100s before ab gives up.

My questions:

  1. What's happening inside node with those "hanging" connections, are they just sat there eating up memory?
  2. What could be causing the apr_socket_recv?
  3. The number of connections which occur before the failure seems to vary, is there any significance to it?

@davetapley
Copy link
Author

Additionally, I found you can pass -r to ab to have it ignore socket errors.
When I use that I actually start to see some requests being completed:

Completed 100 requests
Completed 200 requests
apr_pollset_poll: The timeout specified has expired (70007)

What could be happening here?
Does express or node know to time out and close the connections?

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