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.
Related
VB.NET Server Does Not Receive Connection Requests from Remote Clients
A VB.NET server application does not see connection requests from another client on the network (i.e. with a different IP address). However, it does see connection requests from the client application running on the same computer as the server.
The listening socket is created with the following parameters
System.Net.Sockets.AddressFamily.InterNetwork
System.Net.Sockets.SocketType.Stream
System.Net.Sockets.ProtocolType.IP
We have experimented with the preceding without success.
The endpoint to which the listening socket is bound specifies the local IP address and a specific port number.
The wait-for-connection code is textbook asynchronous:
thelistener.Listen(10)
thelistener.BeginAccept(New System.AsyncCallback(AddressOf targetofaccept), thelistener)
If the client that attempts connection is on the same computer as the listener, then targetofaccept is run successfully. If the client that attempts connection is on some other computer on the network, then targetofaccept is not run.
The behavior occurs for any other client on the network (i.e., not just one).
Thinking that there was some firewall issue, we created VB6 servers and clients using the same addresses and ports. The VB6 server will receive connection requests regardless of the client system.
There is no other issue with communication between clients and the server, as far as we can see. The network architecture has not been modified for a number of years.
We are debugging the code as a VB.NET console application.
Any tips on how to diagnose appreciated.
Before calling Listen() you need to bind your listener socket to the address 0.0.0.0 (in .NET IPAddress.Any) so that it listens to connections from any IP address.
This can be done using the Socket.Bind() method:
Dim listenerEndpoint As New IPEndPoint(IPAddress.Any, <your port>)
thelistener.Bind(listenerEndpoint)
thelistener.Listen(10)
Thank you.
Issue WAS firewall. Fixed by finding exact location of the IDE (devenv.exe), opening "Windows Firewall" in the control panel, selecting "Allow a program or feature through firewall", selecting "Allow another program...", browsing to the exact location and selecting the executable, then ensuring "Home/Work (Private)" column is checked for that "Name".
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.
Is it not possible to specify the local client port used for server calls via NetTcpBinding?
NetPeerTcpBinding support this - I find it hard to believe there's no way to specify the local port (and IP Address for that matter) on clients.
I need to be able to use port sharing and I can't do this if I don't know what port the client is listening on. I won't be able to share the port (and IP) with another client so it can connect.
The only work-around I found is something like this:
Client A opens a connection to Server
Server logs the IP and Port of Client A
Server shares this info. with
Client B
Client B should be able to
connect to Client A on specified IP
and Port (in theory)
This is known as TCP/IP NAT hole punching I believe. Anyone with experience in this?
You probably don't understand the communication pattern with NetTcpBinding. It works this way:
The client opens connection to the server
Two-way communication: The client calls the server and gets the response over the same connection.
Duplex communication: The client calls the server. The server stores reference to the channel somewhere (you must implement this). Once the server wants to notify client about anything it takes stored channel and calls the client on the connection established by the client during its first call.
The server never opens connection to the client. The client doesn't expose any address with port for incomming communication. If you want to do that you must implement service on the client in the same way you did it on the server and you must manully send the address and port to the service exposed by the server.
The difference with NetPeerTcpBinding is that there is no real server and any client must be able to get incomming request. NetTcpBinding is for client-server scenarios where the server is the only peer able to process incomming requests. Because of that only the server needs to define an address and a port.
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.
I have a wcf service deployed on mulitple machines on the intranet. User can access the machine through internet by connecting its machine through SSL (secured connection of the client network).
User has a client application to consume web service deployed on mulitple machine on client network.
I get the machine name from the client and dynamically create the url to create the client of the web service in client application as below:
https://machine_name//test/testservice.svc
What will be the best approach to check if the machine on which client is trying to connect is valid and running(up)?
There could be mulitple condting when timeout is expired like network delay in among one of the cause..
you can try and open a telnet on the port you're calling.
if it timed out - there is a problem.
if you want to do it in more stages
1. run nslookup (to see if the ip-name is defind right)
2. run ping (to see if the machine is alive - if there is no firewall that blocks it)
3. run telnet to the listening port.
What I do - I always publish a test method on the WCF service - that doesn't do anything but returns true - so I can check the service fast.
I would recommend using these three commands:
# check we can resolve the host name
host machine_name
# net cat, to check if the port is open
nc -vz machine_name 443
# curl to see if the service is responding at the given URL
curl -I https://machine_name//test/testservice.svc
The above commands can be run from within a Cygwin/Unix shell. To do the same within a .NET project, you can download libcurl-net. The curl command/library call will do a complete check, and if it fails it should be able to tell you approximately where the problem is.