I have a very simple application running on heroku with nodejs and redis. It periodically processes the data sent to it through the ajax post, and saves the data in a list in Redis.
I run the application locally without any problems, where it logs the data sent to it without resubmission. However, when I run it on heroku, I get about 5-10 requests to it before it works, with a rather nonspecific redis error.
Dependencies:
"redis": "~0.7.1",
"hiredis": "~0.1.14",
"redis-url": "~0.1.0"
Writing code in redis (coffeescript):
app.post '/track', (req, res) ->
redis = require('redis-url').connect(app.settings.redis_url)
if(req.body.userid)
key = "locations:#{req.body.userid}"
redis.rpush key, JSON.stringify({time: (new Date()).toString(), lat: req.body.latitude, lon: req.body.longitude})
The error I am getting is as follows:
Error: Uncaught, unspecified 'error' event.
2012-04-21T06:12:00+00:00 app[web.1]: at Command.callback (/app/node_modules/redis/index.js:159:29)
2012-04-21T06:12:00+00:00 app[web.1]: at HiredisReplyParser.<anonymous> (/app/node_modules/redis/index.js:256:14)
2012-04-21T06:12:00+00:00 app[web.1]: at RedisClient.return_error (/app/node_modules/redis/index.js:446:25)
2012-04-21T06:12:00+00:00 app[web.1]: at HiredisReplyParser.execute (/app/node_modules/redis/lib/parser/hiredis.js:41:18)
2012-04-21T06:12:00+00:00 app[web.1]: at HiredisReplyParser.emit (events.js:67:17)
2012-04-21T06:12:00+00:00 app[web.1]: at RedisClient.on_data (/app/node_modules/redis/index.js:422:27)
2012-04-21T06:12:00+00:00 app[web.1]: at Socket.emit (events.js:67:17)
2012-04-21T06:12:00+00:00 app[web.1]: at Socket.<anonymous> (/app/node_modules/redis/index.js:66:14)
2012-04-21T06:12:00+00:00 app[web.1]: at TCP.onread (net.js:367:14)
This will cause the application to crash, which will eventually return the hero, but then it will quickly work quickly, within a few requests.
- ? node/redis, , , - . , , ...
!