Comments (39)
I've been beating my head against this wall for a full day now. I'm running kue version 0.11 and node 4.5 but still cannot connect to a remote host. here is what my connection looks like:
const config = require('./config');
var Kue = require('kue');
var queue = Kue.createQueue({
redis: {
port: 6379, //process.env.REDIS_PORT,
host: 'DOMAIN_HERE.com' //process.env.REDIS_HOST,
//auth: process.env.REDIS_PASS
},
jobEvents: false,
disableSearch: true,
});
No matter what I try I get the same error back:
events.js:141
throw er; // Unhandled 'error' event
^Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at Object.exports._errnoException (util.js:907:11)
at exports._exceptionWithHostPort (util.js:930:20)
at TCPConnectWrap.afterConnect as oncomplete
I have tried every example I can find and still nothing.. :(
Any help is greatly appreciated.
from kue.
@rvbsanjose make sure if you are calling createQueue(...) before accessing kue.app
express application, and also try with disableSearch: true
.
Finally provide the code so that I can fix it, however I don't believe it is a bug.
from kue.
I'm confused - are you using Kue or reds? I haven't used reds, but in looking at the package.json, it doesn't look like it uses Kue.
If we just focus on Kue and look at your example, you're requiring the node.js Redis client, but not actually overriding the Kue function that creates the client. Try the following to create a Kue instance (named jobs
) with a connection to Redis on example.com:1234
:
var redis = require('redis'),
kue = require('kue');
kue.redis.createClient = function() {
var client = redis.createClient(1234, "example.com");
return client;
}
var jobs = kue.createQueue();
from kue.
I'm using Kue and Kue uses Reds under the hood.
As I stated, it doesn't help if you override the creator function in kue. Your code fails with the same error.
from kue.
What version of Kue are you using? I just ran the above code using Kue 0.2.0 without issue. Your code (and subsequent stack trace) wasn't overriding the Kue creator function - can you provide code that overrides the creator function and the stack trace?
from kue.
I'm using Kue master from Github.
Is there a Redis instance running on your localhost when you tested the code?
from kue.
I'll get this if I use the code you posted (just changed the server and port):
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: Redis connection to 127.0.0.1:6379 failed - ECONNREFUSED, Connection refused
at Socket.<anonymous> (/home/epeli/tmp/kue/node_modules/reds/node_modules/redis/index.js:123:28)
at Socket.emit (events.js:64:17)
at Array.<anonymous> (net.js:830:27)
at EventEmitter._tickCallback (node.js:126:26)
from kue.
Also if add an another Redis instance to my localhost: Both Redis instances, remote and the local, will get connected when I run your code and I won't get the error. Obviously.
from kue.
Ok, I see what's happening now. I was looking at the 0.2.0 release, not master. I have a workaround - it's not pretty, but it works :)
var redis = require('redis'),
reds = require('reds');
reds.createClient = function() {
var client = redis.createClient(1234, "example.com");
return client;
}
var kue = require('kue');
kue.redis.createClient = reds.createClient;
var jobs = kue.createQueue();
from kue.
In order for this to work, you'll need to make sure reds is installed for your application (with npm install reds
) and not installed under Kue (rm -R node_modules/kue/node_modules/reds
)
from kue.
haha the joys of trying to share config like this blah. Yeah, we'll definitely need a reasonable solution for this in the next release. We dont have much choice other than to do kue.reds.createClient = kue.redis.createClient = fn
etc, ugly but other than duplicating a ton of other logic in redis etc there's no easy way around it
from kue.
The thing that makes this tricky is that lib/queue/job.js
and lib/http/routes/json.js
create the reds search when required, so currently you need to override the reds Redis client creation function before Kue is required. This seems less than ideal, so I've created a branch (named lazy-create-reds
) that makes this a bit easier by lazily creating the reds search with an overridden reds.createClient
upon first access.
This change updates lib/queue/job.js
and lib/http/routes/json.js
.
from kue.
it's ideal as far as simplicity goes but yeah im fine with changing it for this
from kue.
@davidwood merged
I wish we could do it with less of a hack, but I can't think of anything off hand
from kue.
I'm with you - it works, but doesn't feel quite right
from kue.
hi,
the problem still exists, with version 0.3.2 :/
is there any fix now? i'm trying to use kue on different machines with one redis server :)
Update: switched to 0.3.1. - everything working fine...
thank you anyway! keep up the good work!
from kue.
I don't understand the assertion that Kue uses Reds under the hood when Reds was written to emulate Kue?
from kue.
@ntresch huh? reds is full-text search, nothing more
from kue.
@visionmedia "I'm using Kue and Kue uses Reds under the hood.", was said by @epeli. I don't believe that this is true, and I don;t understand the assertion, hence the question.
from kue.
it is true, Kue uses Reds for the search
from kue.
That makes more sense, with the qualification "for the search", and I see it now in the source. Thanks!
from kue.
This is still an issue for 0.4.0:
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED
from kue.
Yep same with 0.5.0
from kue.
Pretty sure this is still happening, I can't stop the connection to localhost
from kue.
Still an issue with 0.7.5. Any chance of seeing a fix for this soon?
from kue.
@schonfeld would you provide the code for reproducing this?
from kue.
@schonfeld !!!!????
from kue.
I wandered over from Google, but this is happening to me in a standard node/redis/express app (bare bones..). Running on locahost connecting to a remote redis server (Elasticache on AWS) works fine, but from my EC2 server that doesn't have redis installed I can't seem to connect, since it tries to connect to localhost first even though I have config specific for the remote server running.
Sorry for off-topic, but this was one of few places I found this issue.
from kue.
would u please provide the stack trace of connection error?
from kue.
We forked awhile ago (0.5.0) and updated locally: https://github.com/floored/kue/commit/ec021e07b6ceea9f77bb9556ac2fb8035a880620. Never did a pull request because we assumed it would get fixed "for real".
from kue.
should be fixed in 0.8
from kue.
I'm trying to connect with Redis that is deployed on Heroku and I used the example @davidwood provided but I am still receiving the Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED. Any other ideas on how to fix this?
from kue.
@behrad I feel like a dummy. I was following along with the tutorials and never bothered to read the full doc on connecting. Once I read further down the doc page and followed the instructions, it worked just fine. Sorry for the inconvenience.
from kue.
What was the solution? I am getting this problem after a successful connect to a non-localhost url.
from kue.
@eaglevision20 closest thing I could find: #875
If I have time I'll fork and look..
Maybe check the Pull Requests
from kue.
Still facing the same issue. Tried all the examples and pull requests too. Please help. Its still creating queue with local redis.
Error: Redis connection to 127.0.0.1:6379 failed - connect ECONNREFUSED 127.0.0.1:6379
at Object.exports._errnoException (util.js:907:11)
at exports._exceptionWithHostPort (util.js:930:20)
at TCPConnectWrap.afterConnect as oncomplete
from kue.
@ganeshcse2991 as was said in comment earlier #54 (comment) Problem is requiring app from kue before creating a queue. Something like this: import kue, { app } from 'kue';
At least it was my issue and it is working fine for me now.
from kue.
@behrad thanks for the input about creating the queue
before calling kue.app
you are awesome!
queueService.initQueue(REDIS_HOST, REDIS_PORT);
app.use('/kue-api/', basicAuth, require('kue').app);
from kue.
For those who are still looking for a quick answer:
import kue from "kue";
import express from "express";
kue.createQueue({
prefix: 'q',
redis: {
port: <REDIS_PORT>,
host: "<REDIS_HOST>"
}
});
const app = express();
app.use("/kue-api/", kue.app);
from kue.
Related Issues (20)
- Kue:Listen issue
- Issue with kue singleton instance
- processing a queue in cluster mode fails
- Npm build fails on latest version
- Error: job "xxxxxxx" doesnt exist revisited
- Please deprecate this package OR add a notice to the ReadMe OR add maintainers HOT 7
- Prevent data in failed job list
- remove complete HOT 1
- Dynamic queue
- Waiting for promises to resolve before running next job?
- Not process queued jobs and stuck active jobs HOT 1
- Pug version 2.0.0-beta3
- my solution for stuck jobs in active and inactive state, but is it possible to make this run in every job process? without restart the server
- Hello, i have same issue with completed jobs.
- How to add more attempts in a job HOT 2
- Communicate with job
- Server restart for delayed jobs. HOT 1
- Error: Connection is closed when shutdown ioredis cluster
- NPM audit shows moderate vulnerabilities alert
- you ever thought of using switch?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kue.