{"action":"created","issue":{"url":"https://api.github.com/repos/nodejs/help/issues/1321","repository_url":"https://api.github.com/repos/nodejs/help","labels_url":"https://api.github.com/repos/nodejs/help/issues/1321/labels{/name}","comments_url":"https://api.github.com/repos/nodejs/help/issues/1321/comments","events_url":"https://api.github.com/repos/nodejs/help/issues/1321/events","html_url":"https://github.com/nodejs/help/issues/1321","id":330084578,"node_id":"MDU6SXNzdWUzMzAwODQ1Nzg=","number":1321,"title":"different socket instance when use https.Server","user":{"login":"UchihaYuki","id":38900426,"node_id":"MDQ6VXNlcjM4OTAwNDI2","avatar_url":"https://avatars3.githubusercontent.com/u/38900426?v=4","gravatar_id":"","url":"https://api.github.com/users/UchihaYuki","html_url":"https://github.com/UchihaYuki","followers_url":"https://api.github.com/users/UchihaYuki/followers","following_url":"https://api.github.com/users/UchihaYuki/following{/other_user}","gists_url":"https://api.github.com/users/UchihaYuki/gists{/gist_id}","starred_url":"https://api.github.com/users/UchihaYuki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UchihaYuki/subscriptions","organizations_url":"https://api.github.com/users/UchihaYuki/orgs","repos_url":"https://api.github.com/users/UchihaYuki/repos","events_url":"https://api.github.com/users/UchihaYuki/events{/privacy}","received_events_url":"https://api.github.com/users/UchihaYuki/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-06-07T01:20:50Z","updated_at":"2018-06-07T09:19:24Z","closed_at":null,"author_association":"NONE","body":"* **Node.js Version**: v8.11.1\r\n* **OS**: win10\r\n* **Scope (install, code, runtime, meta, other?)**: code\r\n* **Module (and version) (if relevant)**\r\n\r\nThe following code is a parf of my typescript class. Its basic function is reference counting. It works correctly when I use http server, but breaks when I use https server. The comment embedded gives the detail about my issue. Thanks a lot in advance.\r\n\r\n```ts\r\n    private counter = 0;\r\n    private sockets: { socket: net.Socket, idle: boolean, id: number }[] = [];\r\n    constructor(private server: http.Server | https.Server) {\r\n        server.on(\"connection\", socket => {\r\n            let s = {\r\n                socket: socket,\r\n                idle: true,\r\n                id: ++this.counter,\r\n            };\r\n            logger.debug(`server connection ${s.id}`);\r\n            this.sockets.push(s);\r\n            socket.on(\"close\", (had_error) => {\r\n                let index = this.sockets.indexOf(s);\r\n                this.sockets.splice(index, 1);\r\n                logger.debug(`socket close ${s.id}`);\r\n            })\r\n        });\r\n\r\n        server.on(\"request\", (request: http.IncomingMessage, response: http.ServerResponse) => {\r\n            let s = this.sockets.find((value) => {\r\n                if (value.socket === request.socket) return true; // not equal when server is an instance of https.Server, equal when server is an instance of http.Server\r\n            });\r\n            logger.debug(`server request ${s.id}`);\r\n            s.idle = false;\r\n            response.on(\"finish\", () => {\r\n                logger.debug(`response finish ${s.id}`);\r\n                s.idle = true;\r\n                if (this.isShuttingDown) {\r\n                    s.socket.destroy();\r\n                }\r\n            })\r\n        })\r\n    }\r\n```\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/nodejs/help/issues/comments/395352820","html_url":"https://github.com/nodejs/help/issues/1321#issuecomment-395352820","issue_url":"https://api.github.com/repos/nodejs/help/issues/1321","id":395352820,"node_id":"MDEyOklzc3VlQ29tbWVudDM5NTM1MjgyMA==","user":{"login":"bnoordhuis","id":275871,"node_id":"MDQ6VXNlcjI3NTg3MQ==","avatar_url":"https://avatars0.githubusercontent.com/u/275871?v=4","gravatar_id":"","url":"https://api.github.com/users/bnoordhuis","html_url":"https://github.com/bnoordhuis","followers_url":"https://api.github.com/users/bnoordhuis/followers","following_url":"https://api.github.com/users/bnoordhuis/following{/other_user}","gists_url":"https://api.github.com/users/bnoordhuis/gists{/gist_id}","starred_url":"https://api.github.com/users/bnoordhuis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bnoordhuis/subscriptions","organizations_url":"https://api.github.com/users/bnoordhuis/orgs","repos_url":"https://api.github.com/users/bnoordhuis/repos","events_url":"https://api.github.com/users/bnoordhuis/events{/privacy}","received_events_url":"https://api.github.com/users/bnoordhuis/received_events","type":"User","site_admin":false},"created_at":"2018-06-07T09:19:24Z","updated_at":"2018-06-07T09:19:24Z","author_association":"MEMBER","body":"There's a `tls.TLSSocket` object in between that takes care of encrypting/decrypting data.  Listen for the `'secureConnection'` event instead to get that object; `'connection'` is the plain TCP socket."}}
{"actor":{"display_login":"bnoordhuis"}}