WCF - EndpointNotFoundException, There was no endpoint listening - wcf

My WCF Service is hosted under Windows Service and in case it is not running when client makes a call to its methods, client gets the EndpointNotFoundException with this message:
There was no endpoint listening...
Is there a way I can check if the WCF service is up and running before making calls to the service methods?
Thank you!

Besides just calling it?
You could try pinging it, but that would just tell you that it exists and that its running, not that it's able to accept calls or anything.
UPDATE
To ping the web service you can use the Ping class from System.Net.NetworkInformation.

A solution may be to make a 1st 'dummy' call, if that exception is encountered conclude that it's not running.

You could expose the service contract as WSDL, if possible. If you can reach the WSDL page, then it's running, otherwise it's not.

Related

Nothing happens after adding service to Wcf Test Client

I added the service to the WCF Test Client app and I get Service Added Successfully, but I don't see any of the operations available.
This WCF service is already being consumed by several javascript charts, so I should be able to see something here.
What am I doing wrong?
By default, WCFTestclient doesn’t support call the Restful service by using a client proxy. WCF creates the Restful style service with WebHttpbinding. thereby the client proxy class generates nothing thought the service WSDL is available.
Besides, we are capable of making a successful call to the service by using a client proxy. please refer to the below link.
WCF: There was no endpoint listening at, that could accept the message
the above client proxy class is generated by adding service reference.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/accessing-services-using-a-wcf-client
Here is a detailed exposition of WCFTestClient from Microsoft document.
https://learn.microsoft.com/en-us/dotnet/framework/wcf/wcf-test-client-wcftestclient-exe?redirectedfrom=MSDN
Feel free to let me know if there is anything I can help with.
 

WCF Service through sockets

I have developed a WCF service. Now I want my clients can access to it using sockets. I implemented a TCPListener system on my WCF service, but when I try to instantiate my TCPListener object in a separate thread, I get the following error: An attempt was made to access a Socket in a way that is forbidden by its access permissions.
My WCF service is hosted locally.
Someone to help me please ?
Thanks in advance
You shouldn't let your service implement a socket, communicating is the task of the Binding. You could implement a custom binding which instantiates a TCP channel, some hints here and here. You can also just use the net.tcp Binding, if performance is your goal.
Finally the error you get is pretty clear if you search it on the web: it means you're trying to listen on a port that requires administrative privileges or that is already in use.

Application hanging when the WCF client communicating with the server

I am a beginner with WCF. When I am running the application, it works, but while the client communicates with the server, the application hangs and I can't do anything in the application while it starts communicating. Can you suggest some ideas to rectify this?
Setup an own thread to do the WCF call, one possibility is to use the Thread class, see
http://msdn.microsoft.com/en-us/library/system.threading.thread.aspx
Please note that you have to take special precautions if you process/display result coming back from a WCF call, because this will then be outside of your main UI thread (if you do not use a SynchronizationContext etc...)
The WCF Data Services client API has built in methods to call WCF Data Services asynchronously: http://msdn.microsoft.com/en-us/library/dd756365.aspx

WCF service problem

I created one wcf service lets called as "myService.svc". From my service I am calling client service lets say "clientService.svc". This client service return data to my wcf service.
Today I start getting exception like "There was no endpoint listening at http://clientService.svc that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details...."
So where is this problem probably present inside client service or my service as both service are up so I am not able to figure ut out?
Please help me out.
you web.config has the wrong URL for the client service. Change it to "http://localhost/clientservice.svc".
Check your endpoint configuration... http://clientService.svc is an invalid uri.
Did you try accesing the WSDL via browser?
It seems like the url is wrong maybe in the client, i think it should be something like http://nameofthehost/clientService.svc
to access the wsdl you should add ".wsdl" at the end of the url
How are you running those services? If you are using asp.net development server, its possible, that you got your services running at different ports today. Your inner service's proxy is configured at some address which isn't valid any more. Check the setting and try refreshing the service (right clicking at solution explorer) and possibly change the address or generate proxy again.

wcf service stops after few requests

I am working on an application where i am using a wcf service. I am currently hosting my service on localhost and accessing it from there only by adding the service reference in my project. On one of my page i am sending request on change of selected index on dropdown list. It works fine for first few requests but suddenly stops after that giving following excsption
"Failed to invoke the service. Possible causes: The service is offline or inaccessible; the client-side configuration does not match the proxy; the existing proxy is invalid. Refer to the stack trace for more detail. You can try to recover by starting a new proxy, restoring to default configuration, or refreshing the service."
How can service stop without any reason and that too from my localhost. It only works for first 3-4 requests. In service i am just sending a integer and getting back the records on its basis using a class in a generic list.
Thanks in advance
What protocol / bindings are you using? Can you show us the config? Anything inside the <system.serviceModel> on both the server and the client side.
Do you maybe create a client proxy and call the service method and not properly close and dispose of the client proxy? In that case, you might run out of connections at some point - but that's next to impossible to tell without some code to see what you're doing. Can you show us the service contract in question, and the code how you call it from the client side?