How to ensure that a machine name is valid and running? - wcf

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.

Related

using cloudflared to do ssh tunneling accesible by the interenet without need to run cloudflared on the otherside

I have a raspi machine behind NAT in my room, and I want to access it from the interenet using the URL.I found this article.
https://developers.cloudflare.com/cloudflare-one/tutorials/ssh
However, it required me to run the cloudflared program on the connecting client. I understand that this is for the security purpose. Does it possible to make the connect without running the cloudflared program on the client machine.
A follow-up question would be is it possible to ssh into ipv6 machine that using the same technique.
There are various options when it comes to connecting to a machine running on a private network:
Running cloudflared on the client (which you already found)
Installing the WARP client on the user side, then using cloudflared on the server side to expose the service securely. Finally, route the network traffic for the private network on the tunnel via WARP. This approach is described in a tutorial here
Cloudflare started also supporting in browser rendering of an SSH session. I have wrote a tutorial describing how to set it up here.
Approach (3) would do away with the need of running a client since it relies on a simple browser.

Hosting site using xampp server from local network without port-forwarding

I want to make my site available world wide. Im using xampp server for hosting. I have no access to any kind of servers and modems. Situation is shown below:
My site server has local ip assigned by wifi router and it runs Windows 8.
Remember I have no access on any kind of servers and modems so port port-forwarding is impossible (out of my scope).
Its actually difficult, but not impossible.
One way, I would approach this is:
I would host a page on internet.
Then take request and store it in database.
One of my program will always be running from my computer.
Then check for request and curl the request to localhost. For this you may use Node.js (taking data from database using GET method and curl it to localhost).
This is the best I could think of. And I am working on it, when the code is ready I'll make it open source and notify you :)
But still, it's difficult, as you need to put user's request to sleep for 2 seconds and then transferring it.
Its slow, but may work out for you.
Disadvantages:
Program will be very slow and memory usage will be more.
Breaking may happen many times.
High bandwidth wastage
If not encrypted, MIM (Men in Middle) may possible.
Advantages:
Indirect method of hosting
Need not to worry about your code being lost.
I am looking forward for a better alternative and I would like to keep this question for bounty once again.
If you cannot open the necessary ports within your LAN you will require access to an external server. However, the external server does not need to host any code, e.g.
Create a Linux based ec2 instance using Amazon's free tier.
Install a package to redirect remote to local ports:
a. using socat:
Install socat using your distributions package manager
Connect via SSH: ssh -N -R 42500:127.0.0.1:80 -o ServerAliveInterval=60 ubuntu#xxx.xxx.xxx.xxx -N -R 8080:localhost:80 "socat TCP-LISTEN:8080,fork TCP:127.0.0.1:42500"
b. using a webserver and reverse proxy:
Install apache or nginx and any required reverse proxy modules and configure your VirtualHost to proxy requests to a local port, e.g. :8080 -> 127.0.0.1:42500
Connect via SSH: ssh -N -R 42500:127.0.0.1:80 -o ServerAliveInterval=60 ubuntu#xxx.xxx.xxx.xxx
Your machine is now reachable via the ec2 instance http://xxx.xxx.xxx.xxx:8080/.
I occasionally use this technique when debugging web service callbacks.
Update 17-02-2014
If you are a Windows user you will need to install a third-party tool to support ssh. Options include:
cygwin
git bash
PuTTY
PuTTY is the easiest choice if you are not familiar with *nix tools. To configure remote port forwarding in PuTTY expand the following setting: Connection -> SSH -> Tunnels. Given the previously described scenario, populate Source port as 42500, Desination as 127.0.0.1:80 and tick the Remote option. (You may also need to add the path to a PuTTY compatible private key in the Connection -> SSH -> Auth tab depending on your server configuration.
To test you have successfully forwarded a port, execute the command netstat -lnt on your server. You will see output similar to:
tcp 0 0 127.0.0.1:42500 0.0.0.0:* LISTEN
Finally you can test with curl http://127.0.0.1:42500. You will see the output of your own machines web root running on port 80.
if you don't have a public IP address and cannot use port forwarding it is impossible to host the site
As people have said you need a public IP address. However, even if you did you should not use xampp as a public server, as it is designed for development and therefore has some security settings disabled.
I would recommend buying some shared web hosting, and uploading it to that. (you can get cheap hosting if you google 'shared web hosting', plus free .tk domains are avaliable: http://www.dot.tk/)
Do your company has any vpn network?
If it does and you have access to the vpn network, you can include your server to the vpn network and your guest will only need to login to your company vpn network then access your site like in a local network without using port forwarding. And since your data is very confidential, I assume that using vpn will also help to increase the security of your data.
Please correct me if I'm wrong.
Thank You.
What you are asking is not possible without port forwarding.
Lets break it into steps.
To host your site locally you will need a IP that is static so that
users can access it specifically.
You will need a domain so that it can be converted into user friendly name.
A 24x7 Internet Connection is must! You added a Wifi Router in your Diagram and most of today's router are capable of port forwarding.
What i will do in your scenario is:
Instead of using XAMP, i will install WAMP because i am more familiar with it and easy to configure.(totally personal preference)
Then i would set my server "ONLINE".(Google how to set WAMP server online)
Forward port "80" from router settings to my local computer ip address.(mostly it is tagged as "Virtual Server","Firewall","Port Forwarding",etc vary router to router in settings)
Suppose you have a local ip "192.168.1.3" and global/router IP "254.232.123.232" then you would redirect all the HTTP request done towards router to your local IP.
[[[[254.232.123.232]]]] --+ :80 +-- --------->192.168.1.3
That is good for now, but then you will need to tackle dynamic IP problem of router. But don't worry, thanks to some free sites that will be easy!
Go to no-ip.org -> Setup Account -> and create a entry, just a subdomain for now to test whether everything is working fine.(subdomain like mysite.no-ip.org, later purchase a real Domain)
Input your IP address there(Router IP) and download its application which will automatically update their server if your local IP changes.
Wait for some minutes and Voila! Your site is live.

Unable to connect to different HTTP port on server

I am new to WCF Services, I have developed a WCF service library hosted within a Windows Service. The service end point is http://servername:9980/ApplicationServer/ServiceName.
When I run this service on local system and try to connect using my application, everything works fine.
The problem starts when I deploy this service on server system, none of my application can use this service, even the browser says page not found. Though, if I remove the specific port number from the endpoint all works well.
I have already opened all the ports in Windows Firewall including Client and Server. Also proper exceptions are made to the router firewall, still I am not able to host the service on specific port. I have even tried by switching firewall off on both client and server system.
Thank you in advance.
-Ashish Sharma
When you remove the specific port number it defaults to port 80.
So there is something that is blocking the other port.
Try using the Telnet command to check if the port is open (you may have to enable telnet)
As you have allready checked the firewalls, it could be urlscan or a network device.

WIN2003/IIS6 Ping to Site with Unique IP Times Out

I am adding a new site on a server running other sites, some 'All Unassigned' (those that do not need an SSL) and the is the 4th site with a unique IP (these require an SSL). All other sites, including their SSLs (if applicable) are working.
When I ping the LAN IP from within the network, I get 'request timed out'. Pings to the other unique IPs get a response.
I've tried:
other unique LAN IPs
created a new website in IIS6
created a 'test' folder and pointed IIS there
Event Viewer logs for System or Application show no error messages.
I restarted IIS after each variation.
To my knowledge, pinging from within the network does not go thru my firewall, so I have not fooled with it.
an ASP.NET version issue would ping but throw a browser error, so I have not fooled with it.
Any thoughts on how to debug this issue?
Any suggestions welcome, and Thanks in advance.
Have you added the IP address to the network configuration on the Windows machine?
Ping doesn't have anything to do with your web server configuration or IIS.
To debug:
Make sure under Control Panel -> Network - > under TCP/IP Configuration that your server has the required IPs entered and that your subnet mask entries are correct.
Ping from the command line, so start - > run -> cmd
then at the prompt ping -ip address-
Make sure that your windows firewall is allowing ICMP packets in and out. If your network is protected from the internet by a separate firewall, you can turn the Windows firewall off to test.

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.