I'm implementing a function that receives a file URL, creates a readable stream with axios
, and then pipes that stream to clamscan
with the passthrough
method. However, I always receive COMMAND READ TIMED OUT
in the debug logs and is_infected
is null
. It usually takes around 3 minutes to respond.
This is the simplified code.
const nodeClam = new NodeClam()
const clam = await nodeClam.init(clamScanOptions)
const scanRemoteFile = async (url: string): Promise<ScanResult> => {
let fileStream: ReadStream
try {
// Get a readable stream from this URL
const res = await axios({
method: 'GET',
url,
responseType: 'stream',
})
fileStream = res.data
} catch (e) {
console.error(e)
}
// Send output of this file stream to ClamAV
const av = clam.passthrough()
fileStream.pipe(av)
return new Promise((resolve, reject) => {
av.on('scan-complete', (result) => {
resolve(result)
})
// other listeners
})
}
node-clam: DEBUG MODE ON
node-clam: Could not verify the clamdscan binary. [Error: ENOENT: no such file or directory, access '/usr/bin/clamdscan'] {
errno: -2,
code: 'ENOENT',
syscall: 'access',
path: '/usr/bin/clamdscan'
}
node-clam: Could not verify the clamscan binary. [Error: ENOENT: no such file or directory, access '/usr/bin/clamscan'] {
errno: -2,
code: 'ENOENT',
syscall: 'access',
path: '/usr/bin/clamscan'
}
node-clam: Initially testing socket/tcp connection to clamscan server.
node-clam: using remote server: xxx.xxx.xxx.xxx:3310
node-clam: Established connection to clamscan server!
node-clam: PONG!
node-clam: Established connection to clamscan server!
node-clam: Socket/Host connection closed.
node-clam: using remote server: xxx.xxx.xxx.xxx:3310
node-clam: ClamAV Socket Initialized...
node-clam: Doing initial transform!
node-clam: Got result! COMMAND READ TIMED OUT
node-clam: Error Response: COMMAND READ TIMED OUT
node-clam: File may be INFECTED!
node-clam: Processed Result: {
is_infected: null,
viruses: [],
file: null,
resultString: 'COMMAND READ TIMED OUT'
} COMMAND READ TIMED OUT
node-clam: ClamAV socket has received the last chunk!
node-clam: Error Response: COMMAND READ TIMED OUT
node-clam: File may be INFECTED!
node-clam: Result of scan: {
is_infected: null,
viruses: [],
file: null,
resultString: 'COMMAND READ TIMED OUT'
}
node-clam: It took false seconds to scan the file(s).
Files can be scanned normally.