472,806 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,806 software developers and data experts.

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

"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

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

Thanks to all in advance

Mike Grishaber

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
//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
/// EndProcessRequest. After BuildRequest is called the Async object is
/// 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
//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
/// the Async as parameter. From here we can get the correct http context of
/// 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;

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
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
if(Sink != null)
NewResult.ProfileID.ToString(), NewResult.LanguageID.ToString(),
Sink = null;
catch(Exception e)
LogEntry entry = new LogEntry(LogEntry.WARNING,
"Exception Closing HTTPSink.\r\n" + e.Message,
if(m_Logger!= null)
m_Logger.LogMessage(entry, true);
//unmap sink in ResultRouter

Nov 16 '05 #1
0 3753

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

Similar topics

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...
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...
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...
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...
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...
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...
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. ...
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:...
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...
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: lllomh | last post by:
How does React native implement an English player?
by: Mushico | last post by:
How to calculate date of retirement from date of birth
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.