Skip to content

Proxy websocket causes file descriptor leak #1510

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
pxgo opened this issue Mar 4, 2021 · 3 comments
Open

Proxy websocket causes file descriptor leak #1510

pxgo opened this issue Mar 4, 2021 · 3 comments

Comments

@pxgo
Copy link

pxgo commented Mar 4, 2021

I have encountered a problem of file descriptor leakage. When the browser is forced to close after establishing multiple websocket connections, the number of file descriptors of the agent program will not decrease. Through the windows resource monitor, you can see that there are a large number of File \Device\Afd in the handles associated with the agent.

In the source code, when an error occurs in the socket from the client to the proxy, the code executes proxySocket.end(), the code is as follows:

// http-proxy/passes/ws-incoming.js:131
socket.on('error', function (err) {
   proxySocket.end();
});

The problem disappeared when I changed proxySocket.end() to proxySocket.destroy().

Excuse me, if you execute proxySocket.destroy(), will there be any other consequences?

@823639792
Copy link

823639792 commented Jul 5, 2021

Same error.
@pengxiguaa 你是怎么解决的?

我在尝试你的 proxySocket.end() to proxySocket.destroy()

@pxgo
Copy link
Author

pxgo commented Jul 15, 2021

Same error.
@pengxiguaa 你是怎么解决的?

我在尝试你的 proxySocket.end() to proxySocket.destroy()

我仅仅修改了 http-proxy/passes/ws-incoming.js:131 这一个地方,只是文件句柄数增加得更缓慢了,但并没有解决问题。

@823639792
Copy link

我的测试结果也是这样的
部分时间是正常的,偶尔内存中Socket对象数就暴增,内存也就跟着暴涨,短时间内涨到1-2G
但通过JS的HeapDump看,JS中只占用了十几兆的内存~

Jimbly pushed a commit to Jimbly/http-proxy-node16 that referenced this issue Dec 28, 2023
muratso pushed a commit to ExodusMovement/node-http-proxy that referenced this issue Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants