port https memory leak fix from socket.io

https://github.com/Automattic/socket.io/pull/1143/files
https://github.com/Automattic/socket.io/issues/1177