minhthuan
minhthuan

Reputation: 201

Node.js Socket hang up error

When using http.createServer with node.js , I get the following error:

events.js:48
    throw arguments[1]; // Unhandled 'error' event
                   ^
Error: socket hang up
at createHangUpError (http.js:1092:15)
at Socket.onend (http.js:1155:27)
at TCP.onread (net.js:349:26)

simple code :

http.createServer(
  connect_cache({rules: [{regex: /.*/, ttl: 60000}]}),
  function(b_request, b_response){ ..... }
);

so , what does error mean ? and how can i fix it ?

thank !

Upvotes: 1

Views: 644

Answers (1)

ebohlman
ebohlman

Reputation: 15003

http.createServer() expects at most a single function as its argument, which is then set as the handler for the request event. connect_cache() doesn't have the correct signature to be a handler. Presumably it's written as middleware to be used under Connect or something (like Express) built on it, but you can't pass Connect middleware directly to an instance of http.Server; you need to create a Connect object, pass the middlware to it, and then pass the Connect object to http.createServer().

Upvotes: 1

Related Questions