How to manage stuck jobs in Kue? - javascript

I'm using Kue to create jobs for my MEAN.js app. If the application is idle for some time the Redis connection is closed, apparently Kue is trying to process jobs while the connection is closed, and I get some errors.
I'm watching for stuck jobs every 6 seconds, but this doesn't seem to help avoid the errors.
app.jobs.watchStuckJobs(1000 * 6);
These are the errors I'm getting, for each job I'm processing, after the connection is closed and before the connection is restored:
ERROR: { [Error: Redis connection to XXX failed - read ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'read' }
ERROR: { [AbortError: Redis connection lost and command aborted. It might have been processed.]
code: 'UNCERTAIN_STATE',
command: 'BLPOP',
args: [ 'q:send-email-invitations:jobs', 0 ],
origin: { [Error: Redis connection to XXX failed - read ETIMEDOUT] code: 'ETIMEDOUT', errno: 'ETIMEDOUT', syscall: 'read' } }
I've been reading the Kue documentation for stuck jobs, but the solution they recommend is using Domains, which for the Node version I'm using is deprecated; using promises or binding the error to uncaughtException, which will lose the error context.
What's the best approach in this case, so I don't lose the error context, and I can trace what's happening with the jobs?
If I have to choose one of these options, which is the best I can choose and why?
Is there any Redis configuration or anything outside Kue that I need to be aware of?

Related

HTTP 6369: SOCKET ERROR: read ECONNRESET - Node server connecting to Filemaker Data API

I have run into this error with my Node server when trying to access a Filemaker Server driven backend both locally and remotely.
HTTP 6369: SOCKET ERROR: read ECONNRESET Error: read ECONNRESET at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
After trying everything I can find, triple-checking my FMS settings and logs, restarting the server and the machine several times, I cannot figure out what exactly is going wrong and how to solve it.
I have seen some answers to similar questions here on SO, but for the most part they just suggest catching the error in the express route (has not been changed for months and was working fine before the error), which I have done but it just outputs a more verbose version of the main error above:
HTTP 6369: SOCKET ERROR: read ECONNRESET Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
at TLSSocket.Readable.on (_stream_readable.js:838:35)
at tickOnSocket (_http_client.js:691:10)
at onSocketNT (_http_client.js:744:5)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
at ClientRequest.onSocket (_http_client.js:732:11)
at setRequestSocket (_http_agent.js:436:7)
at handleSocketCreation_Inner (_http_agent.js:429:7)
at oncreate (_http_agent.js:286:5)
at Agent.createSocket (_http_agent.js:291:5)
at Agent.addRequest (_http_agent.js:248:10)
at new ClientRequest (_http_client.js:296:16)
at Object.request (https.js:314:10)
at Request.start (/Users/******/Documents/*****/code/******/node_modules/request/request.js:751:32)
THE ERR : Error: read ECONNRESET
at TLSWrap.onStreamRead (internal/stream_base_commons.js:205:27)
at TLSSocket.Readable.on (_stream_readable.js:838:35)
at tickOnSocket (_http_client.js:691:10)
at onSocketNT (_http_client.js:744:5)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
---------------------------------------------
at ClientRequest.onSocket (_http_client.js:732:11)
at setRequestSocket (_http_agent.js:436:7)
at handleSocketCreation_Inner (_http_agent.js:429:7)
at oncreate (_http_agent.js:286:5)
at Agent.createSocket (_http_agent.js:291:5)
at Agent.addRequest (_http_agent.js:248:10)
at new ClientRequest (_http_client.js:296:16)
at Object.request (https.js:314:10)
at Request.start (/Users/********/Documents/*******/code/******/node_modules/request/request.js:751:32) {
errno: 'ECONNRESET',
code: 'ECONNRESET',
syscall:'read'
}
Also, my Node API in general had already been operating more or less seamlessly for several months of development before this problem arose. One thing was that changed on my machine was my company adding ScaleFusion device management software. I mentioned before the install that it could cause problems with the Node server API calls and the error only happened after ScaleFusion was added. Maybe it is possible the software is causing this problem?
Have been trying to find a fix for a couple of days now but running out of leads on it. If anyone can help out I'd really appreciate it. Thanks in advance for any suggestions.

Discord.JS TLS errors

I have been working on a bot for some time now. Since I updated it to v15.5.0, after a while it works fine, does exactly what I want but then crashes, giving the following error. This seems to be a TLS issue.
Error: Client network socket disconnected before secure TLS connection was established
at connResetException (node:internal/errors:631:14)
at TLSSocket.onConnectEnd (node:_tls_wrap:1565:19)
at TLSSocket.emit (node:events:388:22)
at endReadableNT (node:internal/streams/readable:1305:12)
at processTicksAndRejections (node:internal/process/task_queues:80:21)
The source code for the bot is here
Will I have to downgrade? If so, to what version of node?
I'm using this on a Windows 10 64bit computer with no proxy settings whatsoever.
This is not related to Node.js v15, but it seems like it is an issue on your end (with your connection, or your computer). this question may help you to resolve your issue.

SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac:s3_pkt.c:535:

I am using Requests js to make http requests. My script makes a GET request every 1 minute to an url that is secured over SSL. For 3 hour, everything works totally ( It made over 150 requests successfully). Suddenly, my node js app crashed and printed this error:
SSL routines:SSL3_GET_RECORD:decryption failed or bad record mac:s3_pkt.c:535
at _errnoException (util.js:1022:11)
at WriteWrap.afterWrite [as oncomplete] (net.js:880:14) code: 'EPROTO', errno: 'EPROTO', syscall: 'write' }
The error stack trace pointed me to an error in request js result.
What does the above error mean? How to catch it and prevent it to happen again in the future?

Node.js HTTP GET “ECONNRESET” Error on read

I've read all the related issues on SO and GitHub about this error and none of them seem to address this situation.
When I run the following code:
response = await axios.get('http://localhost:8082/panda, {
httpAgent: new http.Agent({ keepAlive: true, keepAliveMsecs: 10000 })
});
I get the following error:
{ Error: socket hang up
at createHangUpError (_http_client.js:345:15)
at Socket.socketOnEnd (_http_client.js:437:23)
at emitNone (events.js:110:20)
at Socket.emit (events.js:207:7)
at endReadableNT (_stream_readable.js:1059:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9) code: 'ECONNRESET' }
{ Error: read ECONNRESET
at _errnoException (util.js:1019:11)
at TCP.onread (net.js:608:25)
code: 'ECONNRESET',
errno: 'ECONNRESET',
syscall: 'read',
etc...
There's no stack trace beyond the onread call so it's unclear how I can get any additional information beyond the ECONNRESET error code (-54) passed to the onread method in net.js
This issue happens with every request - it is not intermittent.
A few observations:
when making the same request from chrome or postman the request does NOT fail
attempting to reproduce a successful request from Chrome, by using the same headers, fails
setting the accept header to use 'gzip', etc.. does not help - I have tried all the recommendations including some weird ones like setting the content length and adding a body to the request despite this being a GET request
the error always appears in net.js, but happens with both the request and axios libraries
Here's the interesting part - I can only seem to reproduce this problem reliably when I am hosting the server locally. I am able to reach the dev instance or run the server in vagrant, via a docker container, without issue.
I am running macOS Sierra 10.12.6 if that makes any difference. The server is written in Java and uses the Spring framework. Here is the RestTemplate configuration I'm using for HTTP calls:
#Bean
public RestTemplate restTemplate() {
//request timeout
int timeout = 5000;
//Connection Pooling factory with timeouts to prevent disastrous request responses
HttpComponentsClientHttpRequestFactory cf = new HttpComponentsClientHttpRequestFactory();
cf.setReadTimeout(timeout);
cf.setConnectTimeout(timeout);
cf.setConnectionRequestTimeout(timeout);
return new RestTemplate(cf);
}
I've tried messing around with these settings with no luck.
Any ideas?
I have the same issue. The cause was in my proxy settings. I make proxy-port localhost:8080 to my localhost:3000. That's why all API requests from my NodeJS app to localhost:3000 returned "ECONNRESET" Error. When I delete proxy-port, the issue was resolved. Check your net settings. Maybe it's redirecting problem
This was a known issue with NodeJS and has been resolved. Please see http.Agent: idle sockets throw unhandled ECONNRESET for details.
Also ensure you have enabled the correct security settings when opening a port on MacOS

Error starting a test with testacular

I am trying out the angularjs tutorials on a 64 bit Windows 7 system because I find this framework quite interesting from what I read on its home page. I am a newbie to node.js and not experienced in Java-Script.
When running the tests, I get the following error. Can anybody find out what the problem is or give some hints how to determine that? I have a fresh Installation of node and added testacular with
npm install -g testacular
which worked fine from what was printed on the console window.
So here is the error message:
PS C:\Users\xx\Documents\Angular\angular-phonecat> .\scripts\test.bat
INFO [testacular]: Testacular server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
ERROR [testacular]: { [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }
Error: spawn ENOENT
at errnoException (child_process.js:948:11)
at Process.ChildProcess._handle.onexit (child_process.js:739:34)
Short answer:
Set env variable CHROME_BIN to full path to chrome.exe
The error msg is confusing, as the behavior of spawn got changed in Node 0.10, we need to update it (https://github.com/karma-runner/karma/issues/452)
Inserting 'PhantomJS' for the test browser in the karma configuration file on Windows Vista resulted in the same error message: { [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }
I ad-libbed on the advice above and inserted in the system path ("Environmental Variables") under "User variables for owner" PHANTOMJS_BIN with the value consisting of the path including phantomjs.exe (C:\Program Files\phantomjs-1.9.0-windows\phantomjs.exe)
All good, jasmine angularjs tests running now and much faster than with 'Chrome' or 'Firefox' as the test browser.

Categories

Resources