473,467 Members | 1,577 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

IHttpAsyncHandler .NET Remoting error

Hello All,

I am using an IHttpAsyncHandler class to intercept HTTP Requests and forward
them to a system which processes the Request and returns the Result.
I use .NET Remoting to connect the IHttpAsyncHandler object to the System
and transfer the Request and Result between the two.
This works fine for quite a while, and then I start to get the following
error.

"This remoting proxy has no channel sink which means either the server has
no registered server channels that are listening, or this application has no
suitable client channel to talk to the server"
At this point I can't access the IAsyncHandler objects and the Server has to
be restarted.

As a note, the IHttpAsynHandler objects are managed in a pool by IIS.

In order to maintain the HTTPContext for the request, the system caches the
IHttpAsyncHandler Proxy until the request is processed, and then returns the
Result via this proxy instance. It is at this time that I get the
exception.

I am attaching some sample code for the client and server.

Thanks to all in advance

Mike Grishaber
mg********@cp.org

The following is code from the Client. Note that this runs under IIS as an
asp.net IHttpAsyncHandler.

The InitializeChannel method creates the .NET Remoting connection to the
server called m_RequestManager.

/// <summary>
/// This method will register tcp channel and connect to RequestManager.
/// </summary>
protected override void InitializeChannel()
{
//Register channel if not already registered
//create TcpChannel with port set to 0. Giving it as 0 instead means
//that the framework should look for a free port and use this.
m_Channel = new TcpChannel(0);
//Register Channel
ChannelServices.RegisterChannel(m_Channel);
//set registered flag to true
m_ChannelIsRegistered = true;
m_RequestManager = null;
m_RequestManager =
(RequestManager)Activator.GetObject(typeof(Request Manager),"tcp://" + HOST +
":" + PORT + "/" + URI);
}
The next method BeginProcessRequest() is called by IIS when the HTTPRequest
is received. The IHttpAsyncHandler object will connect to the
RequestManager server and send the request. An IAsyncResult object is
returned to IIS so that we can retieve the IHttpAsyncHandler from the pool
when we need it.

/// <summary>
/// This method is called asynchronously by ASP.Net. In this method we
create a
/// Async object which allows us to keep track of state between this method
and
/// EndProcessRequest. After BuildRequest is called the Async object is
returned
/// to IIS. EndProcessRequest will not be invoked intill
m_Async.SetCompleted() is
/// called.
/// </summary>
/// <param name="context">Http context object.</param>
/// <param name="cb">Call back method</param>
/// <param name="extraData">asyncState</param>
/// <returns>Async object</returns>
public IAsyncResult BeginProcessRequest(HttpContext context,
System.AsyncCallback cb, object extraData)
{
//create Async class to return to IIS
m_Async = new Async(cb,extraData);
//get context to use output stream
m_Async.context = context;
//create request object
m_Request = new Cp.Util.Request();
//set request paramaters
m_Request.Parameters = new
NameValueCollection(m_Async.context.Request.Params );
//set Request ID using IDGenerator class. IDGenerator uses .Net GIUD Class.
IDGenerator RequestGiud = IDGenerator.GetInstance();
//set request id with unique id using .Net GUID class
m_Request.ID = RequestGiud.GetID("Pre","Suff");
//pass request object and (this)sink to requestmanager
m_RequestManager.NewRequest(m_Request,this);
//return object to IIS
return m_Async;
}
The next method EndProcessRequest() is called when processing is completed
and the Server has sent back the Result. The IAsyncResult object is invoked
and IIS will call EndProcessRequest().

/// <summary>
/// Called by IIS by when request is ready to stream content to client. IIS
passes
/// the Async as parameter. From here we can get the correct http context of
the
/// clients request and send the response stream back.
/// </summary>
/// <param name="result">Async object</param>
public void EndProcessRequest(IAsyncResult result)
{
//get Async object from IIS
Async async = (Async)result;
//write result to client
async.context.Response.StatusCode = m_StatusCode;
async.context.Response.Write(m_ResponseString);
this.Close();
}

The following is the Server side code....

The next method RegisterChannel() sets up the .NETRemoting server.

/// <summary>
/// This method will registar our TCP Server Channel.
/// </summary>
protected virtual void RegisterChannel()
{
//create binary server formatter
System.Runtime.Remoting.Channels.BinaryServerForma tterSinkProvider provider
= new System.Runtime.Remoting.Channels.BinaryServerForma tterSinkProvider();
//set formatter TypeFilterLevel to full to allow passing of delegates and
object references over Remoting boundaries
provider.TypeFilterLevel =
System.Runtime.Serialization.Formatters.TypeFilter Level.Full;
//create tcp server channel
m_Channel = new TcpServerChannel("RequestManagerChannel",m_Port,pr ovider);
ChannelServices.RegisterChannel(m_Channel); //registar channel
}

The next method is the NewRequest() method which is exposed as a remoting
interface for the client to call.

/// <summary>
/// This method will receive new RequestSink from sink classes.
/// Request object and ID will be mapped by MapRequest method. Request
object will
/// be sent to transaction sub-system.
/// </summary>
/// <param name="Sink">RequestSink</param>
public void NewRequest(Cp.Util.Request InRequest,RequestSink Sink)
{
//map Request
m_ResultRouter.MapRequest(InRequest.ID, Sink);
//send request to outbox
m_TransactionOutBox.SendObject(InRequest);
}
The next method is the Run() method which receives the Result back for the
request, retrieves the IHttpAsyncHandler proxy instance and sends the Result
to it. It is at this point that the exception occurs.

public void Run()
{
//begin send stream process on sink
try
{
if(Sink != null)
{
Sink.SendStream(NewResult.ReturnObject.ToString(),
NewResult.ProfileID.ToString(), NewResult.LanguageID.ToString(),
NewResult.IsSuccess);
Sink = null;
}
}
catch(Exception e)
{
LogEntry entry = new LogEntry(LogEntry.WARNING,
"Exception Closing HTTPSink.\r\n" + e.Message,
"Cp.Request","RequestManager.Run");
if(m_Logger!= null)
{
m_Logger.LogMessage(entry, true);
}
}
//unmap sink in ResultRouter
m_ResultRouter.UnmapRequest(NewResult.ID);
}

Nov 16 '05 #1
0 3814

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Richard Bell | last post by:
I have a class in a seperate dll which I want to remote. I have referenced the class and registered it using a simple exe. I can connect to the class's interface using Activator.GetObject and call...
4
by: Uchiha Jax | last post by:
Hello everyone, I am a plenty silly person who is trying to learn .NET remoting through trial and error (all articles I read are going over my head at the moment (mostly) so I thought i'd give...
0
by: Martijn Damen | last post by:
Hi, At the moment I am trying to develop an application that uses another app over .net remoting and having some problems with it (ok, that is ofcourse why I am here), hope somebody can shine a...
1
by: buzz | last post by:
I am evaluating Mike Woodring's custom thread pool classes (Developmentor) for use with an ASP.NET project that will be implementing pages derived from IHttpAsyncHandler. (Recommended by the...
0
by: Brad Quinn | last post by:
I have a question about the correct way to handle exceptions. Most of the sample code I have seen doesn't address this. My BeginProcessRequest looks like any other. public IAsyncResult...
5
by: LGHummel | last post by:
I'm trying to host a remoting app in IIS and am getting the following error: Failed to execute the request because the ASP.NET process identity does not have read permissions to the global...
0
by: Kirk | last post by:
I'm trying to use a Web Service to be a Remoting client of an existing ..NET 2.0 server. But I get the following error when I try to use System.Runtime.Remoting.Channels.Http in my WebService. ...
1
by: =?Utf-8?B?Z2hhdXNl?= | last post by:
I'm trying to stream in image from another domain asynchronously. My ashx looks like this: <%@ WebHandler Language="VB" Class="Handlers.AsyncImageHandler" Debug="true" %> Here is the vb:...
2
by: =?Utf-8?B?U3RldmUgV3JpZ2h0?= | last post by:
Hi All, This is my first time using this interface, so I am sure I am just missing something stupid. When my Http Handler gets called, the Begin runs and the delegate runs, but the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.