• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2324
  • Last Modified:

Unable to use use WCF from a windows service

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
rudy2024
Asked:
rudy2024
2 Solutions
 
guveraCommented:
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
 
rudy2024Author Commented:
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
 
EDDYKTCommented:
can you run from windows service as specified user instead of systEM?

try it first
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
rudy2024Author Commented:
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
 
Snarf0001Commented:
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
 
rudy2024Author Commented:
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now