网络计时问题导致PHP抛出“无法打开流:没有这样的文件或目录”

We have three mail servers with PHP mail apps running on them. We have a .NET job running on a separate server which uploads contacts photos from facebook, stores them in a temporary location on a NAS, then calls the PHP mail app to tell it to move the image from the temp location into the contact record.

This job, with no code changes, worked fine we had only one mail server, with the temp files being stored locally on it. Now that we moved to a load balanced config, with the temp files on a NAS box, there are wierd timing issues.

In our .NET app, after downloading the photo, before sending the request to our mail app, we get a FileInfo object and check if the file exists, just to be sure. Then we send the request to PHP, which now intermittently throws: failed to open stream: No such file or directory

However, if, after checking fi.Exists in .NET, before sending the request to PHP we put in a Thread.Sleep(n) the errors reduce. The longer the sleep, the less frequently PHP says the file doesn't exist.

So the file exists, but for some reason if we try to access it too soon after downloading, PHP thinks it doesn't exist.

The code includes checks to see that the file is completely downloaded and is not marked as read-only.

Any ideas what could be causing this issue?

public void Save(string tempPath, string username, string password, bool deleteSrc, string merakController = "", string fileNamePrefix = "")
    {
        FileInfo fi = new FileInfo(tempPath);
        if (fi.Exists)
        {
            Name = (fileNamePrefix ?? string.Empty) + fi.Name;
            FileSize = fi.Length;
            TimeStamp = fi.LastWriteTimeUtc;
            string path = fi.FullName;

            if (string.IsNullOrEmpty(Type))
                throw new Exception("Attachment Type not set");

            IceWarpGroupware_Http gwh = new IceWarpGroupware_Http(username, password);
            string parameters = string.Format("AttName={0}&AttType={1}&AttDesc={0}&AttSize={2}&AttTime={3}", Name, Type, FileSize, Time);

            fi.Refresh();
            if (fi.Length != FileSize)
                throw new Exception("It was still downloading?");//this has never been thrown, so thats not it
            if (fi.IsReadOnly)
                throw new Exception("read only"); //again, never hit, so thats not it

            //adding this line makes it work 100% of the time -- reducing the sleep time makes it start to throw "failed to open stream: No such file or directory" intermittently
            System.Threading.Thread.Sleep(15000);

            bool result = gwh.AddAttachment(m_oid, path, parameters, string.Empty, merakController);
            if (!result)
                throw new Exception("Unable to add attachment \"" + Name + "\"");

            try
            {
                if (deleteSrc)
                    fi.Delete();
            }
            catch { }
        }
        //else
        //  throw new Exception("Temp file not found");
    }