Remote file stream access error

  • Thread starter Thread starter Donald Xie
  • Start date Start date
D

Donald Xie

I'm having an error accessing files opened through .NET
remoting and ISA server. The application seems to work ok
generally. However, if the client connects to the server
through an ISA server, it will get an exception after a
while. It appears to be an ISA problem, but it involves
remoting as well so just thought I'd post it here for a
start. The simplified version of both client and server
components follows:

The server is a .NET Remoting class library hosted in IIS
6 (Windows Server 2003, Standard Edition), and returns a
file stream to the caller:

//----- Simplified server code -----
public sealed class FileServer : MarshalByRefObject
{
public FileStream CreateFileStream(string fileName)
{
// Build the full file path from fileName, and then
return new FileStream(filePath, FileMode.Create);
}
}
//----- End of server code -----

The client simply invoke CreateFileStream remotely and
write to the remote file:

//----- Simplified client code -----
FileServer server = (FileServer)Activator.GetObject
(typeof(FileServer), ServerUrl);
FileStream remoteFile = server.CreateFileStream
("remoteFile.dat");
FileStream localFile = new FileStream("localFile.dat",
FileMode.Open, FileAccess.Read);

BinaryReader reader = new BinaryReader(localFile );
BinaryWriter writer = new BinaryWriter(remoteFile);
byte[] buffer = new byte[1024]; //
hardcoded here for simplicity
long totalBytesRead = 0;
int bytesRead = 0;

do
{
bytesRead = reader.Read(buffer, 0, 1024);
if (bytesRead > 0)
{
try
{
writer.Write(buffer, 0, bytesRead);
totalBytesRead += bytesRead;
}
catch (System.Runtime.Remoting.RemotingException x)
{
Log("Caught remoting exception at {0}:\n {1}",
totalBytesRead.ToString("n"), x.ToString());
}
}
} while (bytesRead == BufferSize);

writer.Close();
localFile.Close();
reader.Close();
localFile.Close();
//----- End of client code -----

It works fine when not not through ISA, even if it takes a
long time to transfer the file. However, if going through
an ISA server, it will get an error after about 5 minutes:

//----- Error -----
10060 - Connection timeout
Internet Security and Acceleration Server

Technical Information (for support personnel)

Background:
When the server, while acting as a gateway or proxy,
contacted the upstream content server, it did not receive
a timely response.
//----- End of error -----

It sounds like the ISA Server was having trouble keeping
the file stream connection going, but I'm really not sure.
Any suggestions are greatly appreciated.

Thanks,
Donald Xie
 
Hi Donald,

Thanks for your posting. Based on my experience, I believe that the problem
relates to ISA Server configuration. I recommend you post this issue to the
following newsgroup:

microsoft.public.isaserver

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Thanks for looking at this. Yes I figured that that's
probably the better place for this, just thought that
perhaps I tackle it from both ends...

Actually I've managed to fix my simplified test version by
setting IE's proxy settings yesterday. But it doesn't
solve my original problem, which has to do with encryption
sink with .NET remoting. I'll try to narrow it down a bit
more before posting again.

Thanks,
Donald Xie
 
Hi Donald,

Thanks for your response. Please feel free to post if you have any problems
regarding .NET Remoting.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top