Solved

Unable to use use WCF from a windows service

Posted on 2011-09-05
6
2,190 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now