Solved

Unable to use use WCF from a windows service

Posted on 2011-09-05
6
2,172 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
Comment Utility
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
Comment Utility
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
Comment Utility
can you run from windows service as specified user instead of systEM?

try it first
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 

Author Comment

by:rudy2024
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

763 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

11 Experts available now in Live!

Get 1:1 Help Now