Error connecting to restful service from server - wcf

I have a WCf service which calls an external restfull service. I have deployed WCF service in windows service environment and i am able to run windows service locally and it worked fine, but when i deploy service in windows server. It gives below error.
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 174.143.127.78:443
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.HttpWebRequest.GetResponse()
Is there anything that needs to be configured on server? Any clue why it worked locally but not on server

OK, the key information in your error message is "connection attempt failed", which tells us that your client never reached the host and then timed out.
So the first thing I'd check is the firewall settings on the host. Your URL (listed in your error message) says you're trying to reach the service on 443 (normally for SSL). Make sure your server has that port open for in and out traffic. BTW, even if you're using SSL in your communication, you don't need to use 443 as your port. You can use any port you want within the range allowed.
If that doesn't work, I'd get a copy of Fiddler running on my client and try again, letting Fiddler act as a middleman proxy to capture and log the information going back and forth. That's usually a good way to debug WCF communication problems.
Also, the easiest way to check whether a web service is reachable is to simply type the URL (format is: http: //servername:port/ServiceName/ServiceMethod) into any browser address bar and hit enter. Doing that will contact the web service and, if you get a WSDL message back, you know you have the right address and that communication can commence.
Good luck. If this answers the question, don't forget to mark it as such.

The server where your service is hosted is trying to communicate with 174.143.127.78:443. That's probably where your RESTful service is deployed. You will have to work with your IT to open ports on these boxes so they can communicate with each other. If that can't be done, try seeing if you can host both your services on the same box.

Related

consuming WCF method via web service getting error only in IIS not in IDE

I have added http://ws.hipcricket.com/api/EndUser.svc as a service reference in a my web service. I am able to consume the methods from the IDE but while hosting the same in IIS I'm getting the following errors:
Error 1:
Could not connect to the (please refer the above url). TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 69.20.116.221:80.
Error 2:
There was no endpoint listening at (please refer the above url) that could accept the message. This is often caused by an incorrect address or SOAP action. See Inner Exception, if present, for more details
Maybe you have a firewall blocking communication from your webserver? When developing on your local machine communications through the proxy may most likely be using your credentials, while the user that the application pool that your application is running under on your IIS server most probably does not have the correct rights.

There was no endpoint listening at http://169.254.2.2:8000/calculator/Calculator

I am getting the below errror when calliong WCF method from windows mobile.
There was no endpoint listening at
http://169.254.2.2:8000/calculator/Calculator that could accept the message. This is
often caused by an incorrect address
or SOAP action. See InnerException, if
present, for more details.
I am able to ping to mobile
Port # 8000 is enabled in my PC Firewall.
I used the basichttpbinding both PC and Mobile side.
Still i am not able to call method from WCF service.
I also got the error "There was no endpoint listening at 'x'" after working on with my client/server setup all morning. My firewall was off, so I tried a few things but nothing seemed to eliminate this problem. Finally I decided to restart my PC and that must have liberated the port. I believe that the port got hung up by me not closing the service connection properly before exiting the application. Anyway, restarting allowed me to connect to the same endpoint again with no further problems.

connecting with WCF client

I am trying to connect to a Java based service from WCF .NET client.
the address of the service is something like https://xxxxx:4444/myownservice
I can successfully access the WSDL on
https://servername:4444/myownservice/?WSDl
but when I run the proxy client , the process is timing out and gave me this error message
"Could not connect to ..... TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond xxxxx:4444
where xxxx is the server name
I tried to telnet the server with the port number, and telnet failed (using server name or its IP address).
I can ping to the server.
My question is:
if I can browser the wsdl with
http://xxxxx:4444/servicename/?WSDL
does it mean that the port 4444 is open?
or not necessarily
It's possible that the service was up and running when you grabbed the WSDL, but that it dropped thereafter. Since you can't telnet to it, I'd say the service is down. Since you can ping it, I'd say the server itself is running. Ping operates on a different port.

Connection refused - nettcp WCF Service from work - client connecting over VPN

Here's the scenario: A client machine has connected to the 'Work network' via VPN (Cisco VPN Client). The work network hosts a machine that has a WCF service with nettcp binding. The client tries to connect to this service and gets an exception as follows:
Could not connect to
net.tcp://workMachine:2010/SomeService.
The connection attempt lasted for a
time span of 00:00:01.3180754. TCP
error code 10061: No connection could
be made because the target machine
actively refused it workMachine:2010.
Things I tried:
Changed the Workgroup of the client
machine to the work network
workgroup
Added domain/username/password for the Windows Networking Password vault, so that it can be used to connect
Changed the wcf service path with an IP address instead of the workMachine name
Checked client machine firewalls and added to allow the wcf client through it
All above failed and didn't work.
Has anyone encountered similar issues?
The client machine is on Windows 7
SecurityMode of the WCF service is set to NONE - so that shouldn't be an issue.
Any insights will be helpful
You may need to supply client credentials explicitly through your proxy object.
Assume that the proxy object in the code below implements one of the ClientBase interfaces.
proxy.ClientCredentials.Windows.ClientCredential.UserName = "clientaccount";
proxy.ClientCredentials.Windows.ClientCredential.Password = "S3cr3t1337Pwd";
Could you - just for testing purposes - expose the same service on the same machine using a HTTP endpoint, and try to connect to that one from your VPN client?
NetTcp is an excellent choice behind the corporate firewall - just don't know how the Cisco VPN client might cause troubles here, that might not show up when using an http-based protocol. Just a wild guess for now, but if you have nothing else to go on, give it a try!
Marc
Just another thought to assist with debugging of these kind of issues, using CMD execute "netstat -a" (you can append the -o switch and find the related process id also) and see if the port in question is currently open, if it isn't you may have an issue with the SMSvcHost.exe (this is the Windows process for managing an IIS hosted TCP Service).
I've had this issue before and rectified it by restarting the following services (obviously you'll need to carefully consider this if you are dealing with a live production system):
NetTcpActivator (Net. Tcp Listening Adapter)
NetTcpPortSharing (Net. Tcp Port Sharing Service)
and possibly if relevant:
NetMsmqActivator (Net. Pipe Listener Adapter)
NetPipeActivator (Net. Pipe Listener Adapter)
Hope this helps someone!
J.

Client unable to authenticate when connecting to WCF service

I have a WCF service hosted in a Windows service. The application is an intranet app, and I have programmatically set the bindings on both the service and the client as:
NetTcpBinding aBinding = new NetTcpBinding(SecurityMode.Transport);
aBinding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Windows;
aBinding.Security.Transport.ProtectionLevel = System.Net.Security.ProtectionLevel.EncryptAndSign;
Both the service and client have endpoints configured with SPNs:
EndpointAddress = new EndpointAddress(uri, EndpointIdentity.CreateSpnIdentity("Service1"));
As far as I know, I have setup the bindings correctly-- and I am usually able to connect to the service just fine. I did however run into a case where on a server running Windows Server 2003 R2, x64, SP2 I get the following exception immediately when the client tries to connect:
INNEREXCEPTION -- Exception Message:
InvalidCredentialException: Either the target name is incorrect or the server has rejected the client credentials.
Stack Trace:
at System.Net.Security.NegoState.ProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.NegotiateStream.AuthenticateAsClient(NetworkCredential credential, String targetName, ProtectionLevel requiredProtectionLevel, TokenImpersonationLevel allowedImpersonationLevel)
at System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider.WindowsStreamSecurityUpgradeInitiator.OnInitiateUpgrade(Stream stream, SecurityMessageProperty& remoteSecurity)
I get the exception when I try to connect to the service from another machine in the domain, but if I connect to the service on the same machine running the service it works fine.
The hosting service itself is running as a domain user account-- but I have tried running the service as a Local System and Network Service to no avail. I have checked the Local Security Policies for the server and didn't see anything amiss (i.e. 'Access this computer from the network' includes 'Everyone').
Anyone have an idea of what could resolve this?
I am wondering if I need to do something in Active Directory with respect to the service's SPN? I have read some about using setspn.exe to register or refresh SPNs, but I haven't needed to do this before. Why would this be working with other configurations but not the one above?
Try and run the service as an account that has local administrator access - if you can't run the service with this much permisison, then I belive you'll need to use setspn.exe as you have alluded to.