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
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