question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to catch `connect` error

See original GitHub issue

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

7reactions
luincommented, Jun 9, 2015

connect always throws when the connection is failed regardless of the value of enableOfflineQueue:

var redis = new Redis({
  host: 'non-exists host',
  lazyConnect: true,
  enableOfflineQueue: false
});
redis.connect().catch(function () {
  console.log('should throw');
});
3reactions
knoxcardcommented, Jul 5, 2019

Oh my sweet Jesus! I finally got this working…it would not work with all those fancy attributes inside of new Redis(). Kept it simple and it’s finally doing what daddy wants!

console.time('Redis')
var Redis = require('ioredis'),
  redis = new Redis()
redis.on('error', err => {
  console.log('REDIS: FAILED')
  process.exit(0)
})
redis.on('connect', () => {
  app.set('redis', redis)
  // continue program logic  
  console.timeEnd('Redis')
})
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can you catch a connection error? - javascript - Stack Overflow
I have tried the try and catch(err) method but the error just pops up. Can't find an article on how to catch server...
Read more >
Catch connection error on programm start - Devart Forums
I have the following Problem: When my Delphi program starts, it tries to create a database connection. If e.g. the provided password is...
Read more >
How to Check and Catch No internet Connection Error - Studio
How to do that ? Thanks in advance! In the catch section, you try HTTP Request (uipath.com) then based on the output status...
Read more >
best way to catch connection error - MSDN - Microsoft
It does not run two exceptions blocks. Another tip for you is use the finally block after the catch block in order to...
Read more >
10.12.2 errors.Error Exception - MySQL :: Developer Zone
The following example shows how we could catch syntax errors: import mysql.connector try: cnx = mysql.connector.connect(user='scott', database='employees') ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found