.NET code errors on WIN 2003 Server

  • Thread starter Thread starter SamCern
  • Start date Start date
S

SamCern

We have written code that downloads our product updates. The code works fine
on Vista and 2008 but fails on Windows Server 2003. On the 2003 server,
smaller files ( less than 33 MB) download without problem but larger files
fail with the error below.
We have tried on several machines with abundant system resources.
Any help will be appreciated.

TID:5 6/24/09 12:37:48.9325592 [Create complete client Test (6);Joe (1)]
Error Code: 1450
System.Net.HttpListenerException: Insufficient system resources exist to
complete the requested service
at System.Net.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32
size)
at SDK_Synchronization_Service.ServerListener.ListenerCallback(IAsyncResult
result)
TID:3 6/24/09 12:37:49.0575672 [Create complete client Test (6);Joe (1)]
Error Code: 1450
System.Net.HttpListenerException: Insufficient system resources exist to
complete the requested service
at System.Net.HttpResponseStream.Write(Byte[] buffer, Int32 offset, Int32
size)
at SDK_Synchronization_Service.ServerListener.ListenerCallback(IAsyncResult
result)
 
Hello Sam,
We have written code that downloads our product updates. The code works
fine on Vista and 2008 but fails on Windows Server 2003. On the 2003
server,
smaller files ( less than 33 MB) download without problem but larger files
fail with the error below.
...
System.Net.HttpListenerException: Insufficient system resources exist to
complete the requested service at System.Net.HttpResponseStream.Write.

Sounds like it is something else than just a memory or disk space issue, and
could be some kind of
external limitation, like one created by a firewall, security application or
quota of some kind. Could this be what you are seeing?

Also, what is the software environment in the affected system(s)? Are there
a lot of other things going on on the server(s)?

Also, could you share some of the code you have so that we could see the big
picture better?

Thanks!

--
Regards,

Jani Järvinen
C# MVP
Vantaa, Finland
(e-mail address removed)
 
Hi Jani
It is definietly not the actually physical resources. Using the same type
device (Dell GX620) running Vista or 2008 Server does not get the error on
larger files. Only 2003 and only on larger files. So we are thinking the
same as you but don't know where to look. Have gone through code and see
nothing obvious.

I will get the code and post in a minute or two.
 
Jani, Here is the code for the listener.


using System;
using System.Collections.Generic;
using System.Text;

namespace HTTP_Test
{
class Program
{
static void Main(string[] args)
{
Listener l_oListener = new Listener();
try
{
l_oListener.Initialize();
Console.WriteLine("Ready...");
}
catch (System.Exception ex)
{
Console.WriteLine("----------------------------------------");
Console.WriteLine(ex.ToString());
}

while (true) System.Threading.Thread.Sleep(10000);
}
}
}






using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.Web;
using System.IO;

namespace HTTP_Test
{
class Listener
{
HttpListener m_oHttpListener = null;

public void Initialize()
{
string l_strPrefix = "http://+:8080/";

m_oHttpListener = new HttpListener();
m_oHttpListener.Prefixes.Add(l_strPrefix);
m_oHttpListener.Start();

m_oHttpListener.BeginGetContext(new
AsyncCallback(ListenerCallback), m_oHttpListener);
//m_oHttpListener.BeginGetContext(new
AsyncCallback(ListenerCallback), m_oHttpListener);
}

private void ListenerCallback(IAsyncResult result)
{
try
{
// Call EndGetContext to complete the asynchronous operation.
HttpListenerContext l_oHttpListenerContext =
((HttpListener)result.AsyncState).EndGetContext(result);
try
{
// Decode the URL
string l_strRequest =
HttpUtility.UrlDecode(l_oHttpListenerContext.Request.RawUrl.Trim('/'));

// restart the asynchronous operation
m_oHttpListener.BeginGetContext(new
AsyncCallback(ListenerCallback), m_oHttpListener);

byte[] l_ResponseBuffer = null;

// Open a handle to the file
using (FileStream l_oFile = new FileStream(l_strRequest,
FileMode.Open, FileAccess.Read))
{
// read the data from the file
using (BinaryReader l_oBinaryReader = new
BinaryReader(l_oFile))
{
l_ResponseBuffer =
l_oBinaryReader.ReadBytes(Convert.ToInt32(l_oFile.Length));
}
}

// store the response data in the HTTP response object
l_oHttpListenerContext.Response.ContentType =
"application/octet-stream";

l_oHttpListenerContext.Response.AddHeader("Content-Disposition",
"attachment;filename=\"" + l_strRequest + "\"");
l_oHttpListenerContext.Response.ContentLength64 =
l_ResponseBuffer.Length;

// this line generates the "insufficient resources"
error message

l_oHttpListenerContext.Response.OutputStream.Write(l_ResponseBuffer, 0,
l_ResponseBuffer.Length);
l_oHttpListenerContext.Response.OutputStream.Close();
}
catch (System.Exception ex)
{

Console.WriteLine("----------------------------------------");
Console.WriteLine(ex.ToString());
}
finally
{
// Send the response to the client and release resources
l_oHttpListenerContext.Response.Close();
GC.Collect();
}
}
catch (System.Exception ex)
{
Console.WriteLine("----------------------------------------");
Console.WriteLine(ex.ToString());
}
}
}
}
 
Back
Top