Avast WEBforum

Business Products => Avast Business => Avast Business for Linux => Topic started by: Alimjan on January 11, 2023, 05:03:12 PM

Title: Avast Rest read timeout
Post by: Alimjan on January 11, 2023, 05:03:12 PM
How to increase socket read timeout(so_rcvtimeo I guess) in avast-rest?
Now when was sent a large(3gb) file to /v1/avast/scan, the avast rest closed the connection after 30 seconds.
Message in logs: ERROR   Session: [7fb9680045f0] read: The socket was closed due to a timeout
Title: Re: Avast Rest read timeout
Post by: Radek Brich on January 11, 2023, 07:45:53 PM
Hi, this timeout is currently hardcoded. I'll check if it can be safely changed to "never".

Note that scanning large files uploaded via the REST API is not optimal. The server first waits for the whole file to be uploaded, then is sends it over a unix socket to another process (avast-rest -> avast), and then finally it is scanned. This means that at some point in time, there are two full copies of the file in memory.
We can optimize this so there will be only one copy at a time (by sharing memory), but that's it.

To avoid copying gigabytes of data over network, you can share the file via a network mount and pass only the path to the scanner. This way, the scanner reads only parts of the file it actually needs (unless you enable the "scan full files" option, in which case it would read the whole file anyway). For large files, this might be more efficient, although also less flexible.
Title: Re: Avast Rest read timeout
Post by: Alimjan on January 11, 2023, 10:31:34 PM
Thank you for your fast reply.
Title: Re: Avast Rest read timeout
Post by: Radek Brich on January 18, 2023, 11:15:19 AM
Version 4.3.0 (released today) adds recv_timeout config option (default changed to 300 seconds) and also fixes the performance / memory consumption issue I've described (there is now only one copy of the file in memory at any point in time).