-
Notifications
You must be signed in to change notification settings - Fork 146
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
feat: closeConnection
by id
#176
Conversation
/** | ||
* Forcibly close a specific pending proxy connection. | ||
*/ | ||
closeConnection(connectionId: unknown): void { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would you need this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because there are no timeouts and if the remote server keeps connection open/hangs up then it will keep the connection open forever, I had the same issue. I resolved it similarly as in this PR but checking if remote upstream server hasn't sent any bytes yet so its considered as a timeout
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for late reply. I think you could override
Line 203 in a6d51fb
onConnection(socket: Socket): void { |
super.onConnection(socket)
).
Alternatively, you could access proxyChainServer.server
to get the underlying native http
server.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We mainly need that to be able to terminate specific connections, if they overuse their data plans.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Thanks for explanation :)
const socket = this.connections.get(connectionId); | ||
if (!socket) return; | ||
|
||
socket.destroy(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Destroy actually doesn't destroy the socket (however it tries to close it). See nodejs/node#27428
closeConnection
by id
No description provided.