Solved

Unable to use use WCF from a windows service

Posted on 2011-09-05
6
2,224 Views
Last Modified: 2012-06-27
I have a windows service and I wanted to add capability to send messages from this service to a terminal.
The problem is that I get the following error when I try to create a channel from my windows service:

"There was no endpoint listening at net.pipe://localhost/8084/MessageRecipient that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details."

However, I verified that using the same code from another terminal I can send messages to the listener terminal shown above.

Following is the code I am using to send the message. The number in the code below corresponds to the process id of the terminal. For simplicity it's shown hardcoded.


string addr = "net.pipe://localhost/8084/MessageRecipient";

ChannelFactory<SMS_svc.WCF.IMessageLogger> factory =
                            new ChannelFactory<IMessageLogger>(
                            new NetNamedPipeBinding(),
                            new EndpointAddress(addr));

            SMS_svc.WCF.IMessageLogger proxy = factory.CreateChannel();
            proxy.LogMessage(msg);
            factory.Close();

Open in new window

0
Comment
Question by:rudy2024
6 Comments
 
LVL 8

Accepted Solution

by:
guvera earned 250 total points
ID: 36483840
Hi,

WCF error "No end point listening at net.pipe://server name:port/service name that could accept the message
Often, While having client and server communication via WCF, one of the typical error that is received is no endpoint is listening. I am blogging the error and resolution for the benefits of all blog readers

Error : There was no endpoint listening at net.pipe://servername:portnumber/ that could accept the message.This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.
Resolution: If you get above error, ensure to follow the below steps
Step 1. Ensure you are pinging the server only if it is started. Normally, this is a typical issue while accessing the service, client pings the server even if it is not started.
Step 2. Ensure that config file in both client and server does not have different address.
Step 3. netpipe/named pipe only works if client and server resides in same machine.Use netTcp binding incase they are not in same machine or if there is any chances in future that both of them does not resides in same machine.

Also, ensure that your IP is been correctly accesed via the client. Normally, this does not happen if you are using load Balancing techniques provider the hardware components.
 
Also Check out the below links

  http://social.msdn.microsoft.com/Forums/en/wcf/thread/7b2739d6-48c5-401b-b9b4-eb1aa3a9b434

Regards
Guvera
0
 

Author Comment

by:rudy2024
ID: 36483945
Thanks Guvera.  I am already following the 3 steps  you descibe.  The code works fine from console but doesn't work from windows service.  The link you sent me helps but does not give code solutions.  It mentions that "impersonation restrictions for netNamedPipeBinding" so maybe that's my issue; however, I don't know how to solve that.  Also towards the end of that link it says to "Check if "Net.Pipe Listener Adapter" service is running in Services management console".  I checked and it was disabled, so I enabled it and tried starting it but got the error message "Windows could not start the Net.Pipe Listener Adapter service on Local Computer.  Error 1075: The dependency service does not exist or has been marked for deletion".
0
 
LVL 26

Expert Comment

by:EDDYKT
ID: 36484126
can you run from windows service as specified user instead of systEM?

try it first
0
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

Author Comment

by:rudy2024
ID: 36484234
No luck either.  I opened services.msc, clicked properties of my service the chose "Log On" tab and selected "This account" then specified my same login and pw.
Still get same error.
0
 
LVL 22

Assisted Solution

by:Snarf0001
Snarf0001 earned 250 total points
ID: 36484404
The error above looks like the wcf service is failing to start in the windows service for some reason.
Even try / catch on wcf often leads to beyond useless error messages, I've had the best luck setting up a trace.

http://msdn.microsoft.com/en-us/library/ms733025.aspx

This logs all the service events to a trace file, you can look for errors in there and they usually pinpoint exactly what the problem is.
0
 

Author Closing Comment

by:rudy2024
ID: 36562710
Sorry for my delayed response.  I decided to install the service on the server that it will be running and I didn't have any issue there.  So for tests on my PC, it's ok to run my service as console and as service it works well on my server. I don't know why I can't connect a listener on my PC.  Anyway, for now the problem is solved.

Snarf,
I obtained the error log and even though it was really long, it basically ended up showing the same error message.  This trace is mainly helpful to know what methods got called but I already knew that.  It doesn't specify any root cause.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question