Skip to content
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

Multiple connections in same time #39

Open
Zippersk opened this issue Feb 10, 2019 · 5 comments
Open

Multiple connections in same time #39

Zippersk opened this issue Feb 10, 2019 · 5 comments

Comments

@Zippersk
Copy link

I have this code:

const smbClient = new SMB2({
  share: '\\\\127.0.0.1\\f',
  domain: 'WORKGROUP',
  username: 'user',
  password: 'pass'
});

function downloadFile (path, destination) {
  smbClient.createReadStream(path, function(err, readStream) {
    if (err) throw err;
    var writeStream = fs.createWriteStream(destination);
    readStream.pipe(writeStream);
  });
}

Then I want download two files:

downloadFile('file1.txt', 'f1.txt')
downloadFile('file2.txt', 'f2.txt')

But I get error: Uncaught Error: connect EISCONN 127.0.0.1:445 - Local (127.0.0.1:45618). When I comment one of the function call (or wait for first one to finish), everythings is fine. It seems that the client is creating new connection for every function call instead of use already created one.

@PachVerb
Copy link

PachVerb commented Jun 5, 2020

i also found it, did you have resolve ?

@Zippersk
Copy link
Author

Zippersk commented Jun 5, 2020

No.

@PachVerb
Copy link

PachVerb commented Jun 5, 2020

No.

The readme file of this tool mentions link management. Perhaps the timeout can be set to 0 when the constructor is initialized, which can solve the problem.

@vdiez
Copy link

vdiez commented Sep 9, 2020

You should check on your side not to execute the second downloadFile is not executed until the first one has finished, either by usse of the callback or by promisifing the calls and chaining them.

Otherwise you will need 2 different SMB connections

@dotlouis
Copy link

dotlouis commented Oct 2, 2024

Old issue, but for posterity, I fixed it by adding autoCloseTimeout: 0 in the SMB2 client options

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

4 participants