@@ -206,14 +206,14 @@ function Pool(poolData){
206206 }
207207 this . active = false ;
208208 if ( this . ssl ) {
209- this . socket = tls . connect ( this . port , this . hostname , { rejectUnauthorized : this . allowSelfSignedSSL } , ( ) => {
209+ this . socket = tls . connect ( this . port , this . hostname , { rejectUnauthorized : this . allowSelfSignedSSL } ) . on ( 'connect' , ( ) => {
210210 poolSocket ( this . hostname ) ;
211211 } ) . on ( 'error' , ( err ) => {
212212 this . connect ( ) ;
213213 console . warn ( `${ global . threadName } Socket error from ${ this . hostname } ${ err } ` ) ;
214214 } ) ;
215215 } else {
216- this . socket = net . connect ( this . port , this . hostname , ( ) => {
216+ this . socket = net . connect ( this . port , this . hostname ) . on ( 'connect' , ( ) => {
217217 poolSocket ( this . hostname ) ;
218218 } ) . on ( 'error' , ( err ) => {
219219 this . connect ( ) ;
@@ -643,13 +643,12 @@ function poolSocket(hostname){
643643 } ) . on ( 'close' , ( ) => {
644644 activePools [ pool . hostname ] . connect ( ) ;
645645 console . warn ( `${ global . threadName } Socket closed from ${ pool . hostname } ` ) ;
646- } ) . on ( 'connect' , ( ) => {
647- socket . setKeepAlive ( true ) ;
648- socket . setEncoding ( 'utf8' ) ;
649- console . log ( `${ global . threadName } connected to pool: ${ pool . hostname } ` ) ;
650- pool . login ( ) ;
651- setInterval ( pool . heartbeat , 30000 ) ;
652646 } ) ;
647+ socket . setKeepAlive ( true ) ;
648+ socket . setEncoding ( 'utf8' ) ;
649+ console . log ( `${ global . threadName } connected to pool: ${ pool . hostname } ` ) ;
650+ pool . login ( ) ;
651+ setInterval ( pool . heartbeat , 30000 ) ;
653652}
654653
655654function handlePoolMessage ( jsonData , hostname ) {
0 commit comments