axiak / filternet

A proxy library that provides easy hooks to manipulate http and https traffic consistently.
https://github.com/axiak/filternet
BSD 3-Clause "New" or "Revised" License
101 stars 32 forks source link

Potential socket leak #1

Open trick77 opened 12 years ago

trick77 commented 12 years ago

Hi,

Thanks for sharing this awesome piece of code (and the funny story around it).

It looks like there's a potential connection leak if the socket (for whatever reason) is gone.

    clientSocket.on('data', function (data) {
        try {
            socket.write(data);
        } catch (error) {
            try {
                clientSocket.end();
            } catch (error) {}
            emitter.emit('error', error, 'httpsSocketData');
        }
    });

If socket.write throws an exception like "This socket is closed", the socket will show up as ESTABLISHED or FIN_WAIT2 until Node.js is being restarted. I've been unable to get rid of the socket, even socket.destroy() won't help.