question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Timeout (control socket)

See original GitHub issue

Describe the bug When i upload large file, i have problem with timeout, file upload full, but not resolving and i’m gettings an error Socket Timeout…

Example code await client.uploadFromDir("videos/" + dirName, "videos/" + dirName).then(() => { console.log('Resolved') resolve() }).catch((err) => { console.log('Rejected') client.close() reject(err) })

Console output Error: Timeout (control socket) at TLSSocket.<anonymous> (C:\croper\node_modules\basic-ftp\dist\FtpContext.js:310:58) at Object.onceWrapper (events.js:308:28) at TLSSocket.emit (events.js:219:5) at TLSSocket.Socket._onTimeout (net.js:476:8) at listOnTimeout (internal/timers.js:536:17) at processTimers (internal/timers.js:480:7)

Which version of Node.js are you using? 12.13.0

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

4reactions
patrickjuchlicommented, Jan 12, 2020

Could you post the whole log output, not just the exception?

My guess is that this is probably a typical problem of FTP. I will use this issue to describe the problem and document the current policy of this library also for future reference.

An FTP client uses two connections, one to send commands and receive answers (control), and another one for file transfer (data). For file transfer it is actually a completely new connection for each file but this is not relevant here. During a long file transfer over the data connection, the control connection sits idle. It is possible that during this time, a router somewhere between client and server disconnects the control connection because it seems inactive. This is not standard behaviour at all but it can happen. Routers either usually don’t do this or then do indeed treat FTP differently by inspecting traffic (!) and know to keep the control connection open. With TLS encryption when using FTPS though, the router can’t inspect traffic and doesn’t know that control and data connection actually belong to an FTP client session. From the outside, these two connections are unrelated and the idle one may be closed.

My guess is that this is what’s happening in your case. Now, what can you do about it?

Some FTP clients send some stuff during file transfer at regular intervals over the idle control connection (NOOP command or something else like PWD). This library opted to not do that because it is not standard behaviour at all and doesn’t work with some servers. The technique has other sideeffects. The current policy is: If you transfer large files that take a long time, you have to take into account that there might be a connection problem anyway just because it’s the internet. You will have to handle this in your code and resume transfer. By doing that you’ll automatically handle the described problem here as well.

Why are automatic retries not built-in? When developing a library like this one, it’s important to define how far you want to go. Is this the model layer for a full-fledged FTP client and all you’d have to do is add a user interface? Or is it one level lower – it covers just the basics of FTP but everything else has to be provided by the programmer. This library took the second approach. The target audience is other programmers. Automatic retries of long-running tasks is not an FTP problem.

Now. Looking at how this library has been used over the last years I can see that a lot of developers have a different understanding, especially beginners. They just don’t know about these problems and do expect the library to handle everything.

I’ll reconsider the decision around this topic. I see that it might be helpful. But it doesn’t have a high priority right now.

0reactions
psr1410commented, Jul 20, 2020

Hi Patrick, We also facing the same issue while downloading larger files(2GB to 6 GB we tested). The control_socket timed out issue. All the file stream was downloaded without any problems(It took around 1hr to download 6GB file). But the real problem occurs here while I’m uploading the downloaded stream to Azure storage it is throwing that control_socket TIMEDOUT issue.

I did what you suggested, Checking the client connection closed or not after each stream chunk downloaded. Interestingly the client connection was active, till the total file downloaded.

How can I check and make control_socket connection active? Can you help me out on this issue?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Version 4 - Error: Timeout (control socket) · Issue #106 - GitHub
Bug Description I used the config from https://github.com/SamKirkland/FTP-Deploy-Action/blob/beta-v4/README.md but it doesn't seem to work ...
Read more >
FTPS server giving Error: Timeout (control socket)
I am trying to connect to ftps server using node js. I am using "https://www.npmjs.com/package/basic-ftp" module. but its giving me ...
Read more >
AFT_CONNECT_FTP::AFT_read_control_msg: socket timeout ...
AFT Job fails with: AFT_CONNECT_FTP::AFT_read_control_msg: socket timeout expired. ... Unable to open FTP data connection. Control-M ...
Read more >
Socket Timeout — An Important and Sometimes Complicated ...
During my experience working with Python, I've had several cases where a network client was left hanging while trying to request a server....
Read more >
FTP "Read Timed out" error - Top 4 causes and how to fix them
FTP Read Timed out error means that the client or server couldn't read data from the source and has given up waiting for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found