错误:Redis连接到10.130.212.246:6379失败 - 连接ETIMEDOUT

时间:2015-12-04 06:07:09

标签: node.js redis sails.js

我有一个风帆应用程序。我正在AWS中运行该应用程序。当我在开发模式(sails lift --verbose)中运行代码时,它工作正常。我可以通过键入Ip和端口号(xx.xx.xxx.xx:1337 /)从浏览器访问它。但是当我在生产模式下运行代码(sails lift --prod --verbose)时,当我尝试使用xx.xx.xxx.xx时,我无法通过ip(xx.xx.xxx.xx)访问它:1337它给我以下错误。

Grunt :: Done, without errors.    

Unable to parse HTTP body- error occurred:
Error: Redis connection to 10.130.212.246:6379 failed - connect ETIMEDOUT
   at RedisClient.flush_and_error  (/home/ubuntu/vka/node_modules/sails/node_modules/connect- redis/node_modules/redis/index.js:142:13)
    at RedisClient.on_error (/home/ubuntu/vka/node_modules/sails/node_modules/connect-redis/node_modules/redis/index.js:180:10)
    at Socket.<anonymous> (/home/ubuntu/vka/node_modules/sails/node_modules/connect-redis/node_modules/redis/index.js:95:14)
    at Socket.emit (events.js:95:17)
    at net.js:441:14
    at process._tickDomainCallback (node.js:492:13) [Error: Redis connection to 10.130.212.246:6379 failed - connect ETIMEDOUT]
Unable to parse HTTP body- error occurred:
Error: Redis connection to 10.130.212.246:6379 failed - connect ETIMEDOUT
at RedisClient.flush_and_error (/home/ubuntu/vka/node_modules/sails/node_modules/connect-redis/node_modules/redis/index.js:142:13)
at RedisClient.on_error (/home/ubuntu/vka/node_modules/sails/node_modules/connect-redis/node_modules/redis/index.js:180:10)
at Socket.<anonymous> (/home/ubuntu/vka/node_modules/sails/node_modules/connect-redis/node_modules/redis/index.js:95:14)
at Socket.emit (events.js:95:17)
at net.js:441:14
at process._tickDomainCallback (node.js:492:13) [Error: Redis connection to 10.130.212.246:6379 failed - connect ETIMEDOUT]

请建议一个可能的解决方案。

1 个答案:

答案 0 :(得分:1)

检查您是否使用IP在session.js中对主机进行硬编码,将其更改为localhost

关于如何在没有端口1337的情况下访问的问题,您需要设置一个反向代理,比如说NginX,只打开端口80进行公共访问,配置nginx来路由到端口80的请求在1337端口上运行的sails应用中,使用类似pm2forever的内容来运行风帆应用。

此处说明了将NginX设置为反向代理的步骤:https://www.digitalocean.com/community/tutorials/how-to-set-up-a-node-js-application-for-production-on-ubuntu-14-04