Protection Engine for Cloud Services

 View Only
  • 1.  .Net ERR_SOCKET_ERROR

    Posted May 04, 2023 09:49 AM

    I'm currently implementing the anti-virus scan client module using .Net SDK. I followed the SDK documentation and implemented the code same way as pasted below. The firewall has been opened between the client and server where SPE services are running. However I keep seeing the error "ERR_SOCKET_ERROR" while running the application. Any guidance is appreciated.

    List<ScanEngineInfo> scanEngineInfo = new List<ScanEngineInfo>();

                scanEngineInfo.Add(new ScanEngineInfo()
                {
                    scanEngineIP = config["ScanService:BaseAddress"],
                    scanEnginePort = Convert.ToInt32(config["ScanService:Port"])
                });
                
                ScanRequestManager scanRequestManager = new ScanRequestManager();
                scanRequestManager.PrepareForScan(scanEngineInfo, 60000, 10000);

                StreamScanRequest streamScanRequest = scanRequestManager.CreateStreamScanRequest(Policy.SCAN, true);
                
                bool startStatus = streamScanRequest.Start(null, null);           

                byte[] buff = new byte[512];
                long bytesToRead = file.Length - 1;
                int buffCapRead = buff.Length;
                int bytesRead = 0;
                Stream fin = new MemoryStream(file);
                do
                {
                    if (bytesToRead >= buffCapRead)
                    {
                        buffCapRead = buff.Length;
                    }
                    else
                    {
                        buffCapRead = (int)bytesToRead;
                    }

                    // Refresh data buffer.
                    buff = new byte[buffCapRead];

                    bytesRead = fin.Read(buff, 0, buffCapRead);
                    // Send the bytes to Symantec Protection Engine
                    bool sendStatus = streamScanRequest.Send(buff);               
                    bytesToRead = bytesToRead - bytesRead;
                } while (bytesToRead > 0);
                if (fin != null)
                {
                    fin.Close();
                }

                Stream resultStream = new MemoryStream();
                var result = streamScanRequest.Finish(resultStream);