inplace of connection.connect();
use -
if(!connection._connectCalled )
{
connection.connect();
}
if it is already called then connection._connectCalled =true
,
& it will not execute connection.connect()
;
note - don't use connection.end();