Question

I am currently building a custom binding which gets HTTP requests from a different source than from a listening TCP socket. When I access and open a channel directly, there are no problems. However, problems occur when I try to host my binding in an endpoint of a WebServiceHost.

I've inserted Console.WriteLine() debug messages into every function of my custom binding's code. Everything works fine until after the OnOpen() function of my ChannelListener has been called. Afterwards, the ServiceModel just doesn't want to invoke the OnAcceptChannel() method. No exceptions, no error message; it just hangs there and doesn't call any other function of my binding anymore. I've commented the output of the application into the code below.

WebServiceHost host = new WebServiceHost(
    typeof(MyService), new Uri("http://localhost:80"));
host.AddServiceEndpoint(typeof(MyService), new MyWebHttpBinding(), "");
// BINDING CONSTRUCTOR
// BINDINGELEMENT CONSTRUCTOR
host.Open();
// BINDING: CreateBindingElements (multiple times)
// BINDINGELEMENT: Clone
// BINDINGELEMENT CONSTRUCTOR
// BINDINGELEMENT: CanBuildChannelListener
// BINDINGELEMENT: Clone
// BINDINGELEMENT CONSTRUCTOR
// BINDINGELEMENT: CanBuildChannelListener
// BINDINGELEMENT: Clone
// BINDINGELEMENT CONSTRUCTOR
// BINDINGELEMENT: Clone
// BINDINGELEMENT CONSTRUCTOR
// BINDINGELEMENT: Clone
// BINDINGELEMENT CONSTRUCTOR
// BINDINGELEMENT: BuildChannelListener
// CHANNELLISTENER CONSTRUCTOR
// BINDINGELEMENT: Clone
// BINDINGELEMENT CONSTRUCTOR
// BINDING: CreateBindingElements (multiple times)
// CHANNELLISTENER: OnOpen
// CHANNELLISTENER: OnOpen END (function completes properly. last output)

Does anybody of you know what I have to change in my application that the OnAcceptChannel method gets called properly?

Cheers

Was it helpful?

Solution

Are you logging calls to the Async version of the ChannelListener methods? I seem to remember ServiceHost trying to call OnBeginAcceptChannel normally instead of OnAcceptChannel.

Also, are you attaching a handler to the ServiceHost.Faulted event? It could be that it's faulting and you won't necessarily get an external exception during the opening of the host.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top