Author Topic: Avast Rest read timeout  (Read 4631 times)

0 Members and 1 Guest are viewing this topic.

Offline Alimjan

  • Newbie
  • *
  • Posts: 2
Avast Rest read timeout
« 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

Offline Radek Brich

  • Developer (Linux AV, Mac AV)
  • Avast team
  • Jr. Member
  • *
  • Posts: 53
Re: Avast Rest read timeout
« Reply #1 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.

Offline Alimjan

  • Newbie
  • *
  • Posts: 2
Re: Avast Rest read timeout
« Reply #2 on: January 11, 2023, 10:31:34 PM »
Thank you for your fast reply.

Offline Radek Brich

  • Developer (Linux AV, Mac AV)
  • Avast team
  • Jr. Member
  • *
  • Posts: 53
Re: Avast Rest read timeout
« Reply #3 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).