How to Set Timeout for Network Operations in aria2c on Ubuntu
This guide explains how to configure network timeouts in aria2c on Ubuntu to prevent hanging downloads. You will learn about specific command-line flags and configuration file settings to control connection and operation timeouts effectively.
Understanding aria2c Timeout Flags
aria2c provides specific options to manage how long it waits for
network responses. The two most critical flags are
--connect-timeout and --timeout. The
--connect-timeout sets the time in seconds to establish a
connection to an HTTP/FTP/FTP proxy server. The --timeout
sets the timeout in seconds for network operations during the download
process.
Using Command-Line Arguments
You can set these timeouts directly when running the aria2c command. This method is ideal for one-off downloads where specific network conditions require adjusted limits. To set a connection timeout of 10 seconds and a network operation timeout of 60 seconds, use the following syntax:
aria2c --connect-timeout=10 --timeout=60 http://example.com/file.zipIf the connection cannot be established within 10 seconds, aria2c will abort. Similarly, if the data transfer stalls for more than 60 seconds, the operation will terminate.
Configuring Permanent Settings
For persistent settings across all downloads, modify the aria2
configuration file. On Ubuntu, this file is typically located at
~/.config/aria2/aria2.conf. If the file does not exist, you
can create it. Add the following lines to define your default
timeouts:
connect-timeout=10
timeout=60
Save the file after adding these lines. Any subsequent aria2c commands will automatically use these values without needing explicit flags.
Verifying Your Settings
To ensure your timeout settings are active, you can check the current
configuration by running aria2c with the
--show-console-readout flag or by reviewing the log output
during a download attempt. If a connection hangs and terminates after
your specified duration, the timeout is correctly configured.