Skip to content

All successful client sockets are not closed #48

@louislam

Description

@louislam

As topic.

If you use this server as a web proxy, because websites nowadays make a lot of requests, it also creates a lot of sockets on socksv5 server. As all successful sockets are not closed, it will eats up all system resources and emits EMFILE error shortly. As a result, the server is no longer working anymore.

After some investigations, in server.js, I found out that after the dstSock (the socket between proxy server and destination server) is closed, it do not close the client socket together.

To fix this, just need to add close event and destroy the client socket.

server.js

function proxySocket(socket, req) {

    ....

    dstSock
            .on('error', onError)
            //////////// Missing Part ///////////
            .on('close', () => {
              socket.end()
              socket.destroy()
            })
           //////////// Missing Part End ////////////////////
           .on('connect', function() {
             connected = true;
             if (socket.writable) {

    ....

However, it seems that this project is abandoned. My recommendation is you should not use this library.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions