Hi,

I am trying to route requests based on a result I get from redis, but I am 
failing miserably.

Consider this pseudo code snippet below:

var proxy = new httpProxy.RoutingProxy();
http.createServer(function (req, res) {
  console.log("URL", req.url);
  if (req.url) {
    var token = req.url.split("/")[1];
    
    // if I leave this code here it works fine
    // var target = { host: 'local-01', port: 8024 }
    // proxy.proxyRequest(req, res, target);

    // now I need to retrieve some routing information
    // from redis, so I query redis here
    redisClient.get(token, function (err, reply) {
      // if I leave this code here the request hangs
      var target = { host: 'local-01', port: 8024 }
      proxy.proxyRequest(req, res, target);
    });
  }
}).listen(routerInfo.port, routerInfo.address);

If I call proxy.proxyRequest before querying Redis, it works fine. However, 
if I move the code inside Redis callbacks, it fails and the HTTP request 
just hangs.

Any idea what's going on here and how to fix it?

Thanks,

-- Felipe.


-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to