473,569 Members | 2,701 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

IHttpAsyncHandl er .NET Remoting error

Hello All,

I am using an IHttpAsyncHandl er 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 IHttpAsyncHandl er 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 IHttpAsynHandle r objects are managed in a pool by IIS.

In order to maintain the HTTPContext for the request, the system caches the
IHttpAsyncHandl er 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.o rg

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

The InitializeChann el method creates the .NET Remoting connection to the
server called m_RequestManage r.

/// <summary>
/// This method will register tcp channel and connect to RequestManager.
/// </summary>
protected override void InitializeChann el()
{
//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 .RegisterChanne l(m_Channel);
//set registered flag to true
m_ChannelIsRegi stered = true;
m_RequestManage r = null;
m_RequestManage r =
(RequestManager )Activator.GetO bject(typeof(Re questManager)," tcp://" + HOST +
":" + PORT + "/" + URI);
}
The next method BeginProcessReq uest() is called by IIS when the HTTPRequest
is received. The IHttpAsyncHandl er object will connect to the
RequestManager server and send the request. An IAsyncResult object is
returned to IIS so that we can retieve the IHttpAsyncHandl er 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
/// EndProcessReque st. After BuildRequest is called the Async object is
returned
/// to IIS. EndProcessReque st will not be invoked intill
m_Async.SetComp leted() is
/// called.
/// </summary>
/// <param name="context"> Http context object.</param>
/// <param name="cb">Call back method</param>
/// <param name="extraData ">asyncStat e</param>
/// <returns>Asyn c object</returns>
public IAsyncResult BeginProcessReq uest(HttpContex t context,
System.AsyncCal lback cb, object extraData)
{
//create Async class to return to IIS
m_Async = new Async(cb,extraD ata);
//get context to use output stream
m_Async.context = context;
//create request object
m_Request = new Cp.Util.Request ();
//set request paramaters
m_Request.Param eters = new
NameValueCollec tion(m_Async.co ntext.Request.P arams);
//set Request ID using IDGenerator class. IDGenerator uses .Net GIUD Class.
IDGenerator RequestGiud = IDGenerator.Get Instance();
//set request id with unique id using .Net GUID class
m_Request.ID = RequestGiud.Get ID("Pre","Suff" );
//pass request object and (this)sink to requestmanager
m_RequestManage r.NewRequest(m_ Request,this);
//return object to IIS
return m_Async;
}
The next method EndProcessReque st() is called when processing is completed
and the Server has sent back the Result. The IAsyncResult object is invoked
and IIS will call EndProcessReque st().

/// <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">A sync object</param>
public void EndProcessReque st(IAsyncResult result)
{
//get Async object from IIS
Async async = (Async)result;
//write result to client
async.context.R esponse.StatusC ode = m_StatusCode;
async.context.R esponse.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.Channe ls.BinaryServer FormatterSinkPr ovider provider
= new System.Runtime. Remoting.Channe ls.BinaryServer FormatterSinkPr ovider();
//set formatter TypeFilterLevel to full to allow passing of delegates and
object references over Remoting boundaries
provider.TypeFi lterLevel =
System.Runtime. Serialization.F ormatters.TypeF ilterLevel.Full ;
//create tcp server channel
m_Channel = new TcpServerChanne l("RequestManag erChannel",m_Po rt,provider);
ChannelServices .RegisterChanne l(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">Req uestSink</param>
public void NewRequest(Cp.U til.Request InRequest,Reque stSink Sink)
{
//map Request
m_ResultRouter. MapRequest(InRe quest.ID, Sink);
//send request to outbox
m_TransactionOu tBox.SendObject (InRequest);
}
The next method is the Run() method which receives the Result back for the
request, retrieves the IHttpAsyncHandl er 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.Retu rnObject.ToStri ng(),
NewResult.Profi leID.ToString() , NewResult.Langu ageID.ToString( ),
NewResult.IsSuc cess);
Sink = null;
}
}
catch(Exception e)
{
LogEntry entry = new LogEntry(LogEnt ry.WARNING,
"Exception Closing HTTPSink.\r\n" + e.Message,
"Cp.Request","R equestManager.R un");
if(m_Logger!= null)
{
m_Logger.LogMes sage(entry, true);
}
}
//unmap sink in ResultRouter
m_ResultRouter. UnmapRequest(Ne wResult.ID);
}

Nov 16 '05 #1
0 3832

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

Similar topics

8
2691
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 it's methods. However, when I use soapsuds to extract meta data, I get the following error: Error: Unable to retrieve schema from url:...
4
3107
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 it a go). What I want to do is this: Have a server instance of the program, this server instance will receive communication from client programs...
0
2418
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 light on the following: I have been given a sample winforms app, which works without problem, I can connect, send queries and become response from...
1
2131
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 famous Fritz Onion article on IHttpAsyncHandler...) I understand most of the code, however I am at a losss of the purpose of the ThreadInfo class. It...
0
1053
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 BeginProcessRequest(HttpContext ctx,AsyncCallback cb,object obj) { AsyncRequestState reqState = new AsyncRequestState(ctx, cb, obj);...
5
1901
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 assembly cache. Error: 0x80070005 Access is denied. I tried adding ASPNET to the Administrators group with no success. The error is preceded by the...
0
755
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. The same code works fine in a standalone app. I have inspected System.Runtime.Remoting.dll with ildasm, and I can see the ....Channels.Http...
1
2559
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: Imports System.net imports system.io Namespace .Handlers
2
3340
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 EndProcessRequest never runs and the page hangs forever. Any idea why? Public Class MyAsyncWebHandler Implements IHttpAsyncHandler Implements...
0
7697
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7612
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8120
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7968
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6283
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5219
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3640
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1212
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
937
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.