@@ -319,21 +319,41 @@ class Client extends EventEmitter {
319
319
var client = new Client ( currConnectionString )
320
320
this . attachErrorListenerOnClientConnection ( client )
321
321
let lookup = util . promisify ( dns . lookup )
322
- await lookup ( client . host ) . then ( ( res ) => {
323
- client . host = res . address
324
- client . connectionParameters . host = client . host
322
+ let addresses = [ client . host ]
323
+ await lookup ( client . host , { family : 0 , all : true } ) . then ( ( res ) => {
324
+ addresses = res
325
325
client . load_balance = false
326
326
client . connectionParameters . load_balance = false
327
327
client . topology_keys = ''
328
328
client . connectionParameters . topology_keys = ''
329
+ } )
330
+ for ( let idx = 0 ; idx < addresses . length ; idx ++ ) {
331
+ client . host = addresses [ idx ] . address
332
+ client . connectionParameters . host = client . host
329
333
if ( Client . failedHosts . has ( client . host ) ) {
330
334
let upHostsList = Client . hostServerInfo . keys ( )
331
335
let upHost = upHostsList . next ( ) . value
332
336
client . host = upHost
333
337
client . connectionParameters . host = client . host
334
338
}
335
- } )
336
- await client . nowConnect ( )
339
+ await client
340
+ . nowConnect ( )
341
+ . then ( ( ) => {
342
+ idx = addresses . length
343
+ } )
344
+ . catch ( ( err ) => {
345
+ client . connection =
346
+ client . config . connection ||
347
+ new Connection ( {
348
+ stream : client . config . stream ,
349
+ ssl : client . connectionParameters . ssl ,
350
+ keepAlive : client . config . keepAlive || false ,
351
+ keepAliveInitialDelayMillis : client . config . keepAliveInitialDelayMillis || 0 ,
352
+ encoding : client . connectionParameters . client_encoding || 'utf8' ,
353
+ } )
354
+ client . _connecting = false
355
+ } )
356
+ }
337
357
return client
338
358
}
339
359
0 commit comments