Mysterious network errors
June 26, 2008 7:59 AM   Subscribe

Why am I getting these mysterious network errors in my C# app?

When using a StreamReader to read from a file across the network, I'm getting a "The specified network name is no longer available" when using a ReadBlock(buffer, 0, buffer.Length) method call. What's puzzling is that my buffer is partially filled when the exception is thrown. Similarly, when I'm writing the data to alternate file streams at the destination file share, I'm getting weird "permission denied" errors. These errors do not show up at all under a reduced load.

I have no doubt that these exceptions are due to the fact that I have several dozen instances of my app running, each of which is using a couple hundred threads that are potentially reading from the same file share simultaneously. But I need to know what the actual root cause of this problem is, so I can solve or work around it.

I've taken the obvious step of throttling my thread pool, and there is retry logic in the code, but I'd still like to know what's going on so I can prevent this from happening. The error message I'm getting is not very helpful.

Am I bumping up against Windows limits on open file handles?

Thanks!
posted by mpls2 to Computers & Internet (5 answers total) 1 user marked this as a favorite
 
For the purposes of this question, assume it is very difficult to reproduce in a debug environment.
posted by mpls2 at 8:05 AM on June 26, 2008


And the file shares are on very sophisticated hardware.
posted by mpls2 at 8:06 AM on June 26, 2008


Are you setting up all of your streams as read only (ie using FileShare.Read and FileAccess.Read)?
posted by burnmp3s at 8:10 AM on June 26, 2008


Well, the limit on open file handles is typically 16,384 by default. You can check this by running "net config server" from the command line. You may be going over that. You might try purposely opening a very large number of file handles (e.g., 15,500) with a simple program, then running your app. If the error occurs much sooner than usual, then that may be the issue.

By default Windows servers can have over 16 million TCP connections open, so I doubt that's the issue.
posted by jedicus at 8:25 AM on June 26, 2008


Difficult to repro in a test/debug environment?

Then you need an in-memory dump, using WinDBG, which can simply be executed from a folder/thumbdrive (touchless, no registry, COM-crap required).

But - that is a very difficult tool to use and understand. You might be better off first using Netmon/Wireshark to determine if, in fact there isn't a network glitch occuring.
posted by jkaczor at 10:38 AM on June 27, 2008


« Older Cushy playroom flooring on a shoestring budget...   |   Tam tam tam tam..... Newer »
This thread is closed to new comments.