nodemailer / smtp-server

Create custom SMTP servers on the fly
Other
846 stars 145 forks source link

Counter for logging active connections #157

Open mbordash opened 3 years ago

mbordash commented 3 years ago

Hi,

In my SMTPserver service I setup the following logic:

onConnect ( session, callback ) {
        connCount++;
        logger.info( 'Number of concurrent connections: ' + connCount );
        return callback();
    },
    onClose( session ) {
        if( connCount >= 1 ) {
            connCount--;
        } else {
            connCount = 0;
        }
    },

This was working great and we were able to track connections over time in grafana, however, one of our customers now proxies requests through a load balancer. Our counters increase due to onConnect but onClose doesn't get called any more. I suspect it is because the loadbalancer now keeps connections open, or perhaps sends "ping/alive" requests which skews the numbers.

Can you advise on a better way to track client connections other than the way I'm doing it above?

Thank you,

Michael