Check to see if Tomcat server is UP from C# - c#

I am working in a multiple server environment and so have created a Management Program to start, stop and open pages on my Tomcat servers.
I want some way to determine from C# whether the server is up at any particular point. I have tried connecting to ports but haven't had any luck. Does anyone know how to do this? Poll a port on an IP address to determine if Tomcat has been bound to it?

What you can do is create a windows service or forms app which uses httpRequests to request a specific page on your tomcat server. This page can for example contain the text "server online"
In the httpResponse class it's possible to read the contents of the returned html code by the server.
If this html contains an error message, your server is probably down or misconfigured,
if it contains the right text, your server is up and running.
You can also try to create a program to check the windows service status for the tomcat service.
Note this will only tell you the service is running, not that it actually works the way it is supposed to.

You have to use JMX in connection with a web service maybe.

Related

Get response back from unpingable websites (C# ASP .net mvc)

I'm not a network expert, but for one of my projects, I need to ensure that the website I'm sending the request to is alive. Some websites do not respond to ping; basically, their configuration prevents response to ping requests.
I was trying to Arping instead of pinging websites, but Arping only works on the local network and will not go beyond the network segment (this).
I can download the whole or part of the webpage and confirm if the content is the same as the previous state, but I rather have one more level of confirmation before downloading Html.
Is there any other method that enables the app to get a response back from non-pingable websites outside the network?
Based on common practices you may use ping, telnet and tracert as a client to the requested server (at this point the website or the service you want to connect) and make sure the 3 command are enable to your side. You may also try to access it to your browser.
If its API you may also try to use POSTMAN and call the service.
Goodluck and happy coding :)

Best way to contact Desktop application remotely via Internet

I want to pass certain parameters to a desktop application remotely via the internet. I don't want my application to contact the server repeatedly, because many such applications can bring the server down easily. Is there a way to initiate the connection from the server? How can I identify the applications, as there will many of them running on many computers somewhere around the globe. I don't know where to start - I'm trying to do this in C# and ASP.NET/PHP on the server-side. Please give some advice.
Is there a way to initiate the connection from the server?
No. Not without having the client contact with the server first, informing it with the IP address, port to use etc... Which the server will need to keep for each client, hoping that they don't change (or get updated when they do change).
Long polling by the client is the right solution for what you are doing, even if you don't want to use it.
There are many different ways you could approach this, just thinking out of the box, both your app and the server could utilize a different mechanism for transferring the settings. I'm not recommending any of these methods, please don't shoot me down, they are all just ideas.
As an example, your server could connect out using FTP and output the updated settings to an FTP server on each PC. You could install something like Filezilla on each machine which runs your app. You'd obviously need to configure port forwarding on the router to allow the server FTP access.
You could use email. Setting up an email account where your server can login to send out the settings. Your app could possibly login to the same email account possibly even a single Gmail account to retrieve the settings.
Another idea would be to use a file sharing service like Dropbox, Google Drive or similar and where the settings could be shared. Obviously this would involve learning any API and I'm not sure if there are any restrictions on this approach.
The last idea and probably my preferred approach would be to host a web service and database on a remote server, both your server and the applications would connect to the same service to transfer the settings. This approach is obviously firewall/router friendly as all the clients connect out to the web service to collect the required data.
Hope this helps?

Consuming Asp.net web service from remote computer

I create Asp.net WS and host it on the IIS.Now i want to consume it from remote computer or another computer.When i insert the URL of the WS on the remote computer an error message appears inside internet explorer browser page says
This program cannot display the web page
i work on Visual studio 2008, windows 7 and the client application is Asp.net website.
i don't know what is the problem??
have i connect the two computers with LAN(make network between them) or just enough each one connect to the internet??
Your computers need to be able to connect to each other.
If they on LAN, then You need to specify LAN address for asp.net WS.
Also check Your firewall for blocking connections, need to be sure that port were IIS hosted is available for connection
If nothing helps, then provide us more information about problem.
Really i don't know what is the problem.When i do the same thing in another computer it runs but on my laptop doesn't run.

Receiving data sent from client machine

I'm working on a project that has a C# app (running 24/7 as a server) on the client's machine). This app needs to send a file as a byte stream via POST to a server I am currently hosting on my home desktop.
Can this file be received by a C# app running on my server, or does it have to be as ASP app/page?
Also, I know how to send a bytestream via POST, but how will I set my server side app to listen for this incoming data?
I have never done something like this, so I'm looking for some pointers to get me started.
Thanks
Depending on what you need to do with the file, and when it's uploaded, there is nothing wrong with using a tiny asp.net app to do this.
If the only way you can get the file to the server is via http POST, why write your own service/daemon to run a listener? Unless you have some reason not to run it in IIS, I would do it there. There is the full stack available that way for authentication and so on if you should happen to need it. Besides, if you have to upload files via http post, I would bet you will end up wanting other methods available via HTTP as well..
You're looking for this guy:
http://msdn.microsoft.com/en-us/library/system.net.httplistener.aspx
Using that, you'll create basically a mini HTTP server, listening on some port you specify. You'll then be able to post data to it, and process it accordingly (similar to if the processing code was in an ASPX code-behind).
Assuming your open to sending directly via TCP you can look at this example if you dont wanna go the HTTP way. I personaly like the NetworkStream Class, for sending data over the network painfree.

Is it possible to write C# code as below and send email using network in different country?

Is it possible to write C# code as below and send email using mnetwork in different country?
MSExchangeWebServiceURL = mail.something.com/ews/exchange.asmx
It's a web service URL. This works great when I run the same code from home network, my friends home network anywhere around, but when I run it from my client's location in Columbia it fails.
I have a valid user name and password on that Exchange Server. Is there any configuration that I can set to achieve this?
BTW this code below works when I run it within office network and any network within any home network. I have tried it at least with five friends network in Plano, Texas. I want this code to work running from any network in another country.
My client in Columbia can connect to the web service using a browser using the same user name and password, but when I run the code above it is not able to connect to our web service.
EDIT: Based on the comments and updated post, I would wager that the client location has a proxy server or firewall that is blocking the traffic. The client probably needs to add the relevant domain to whatever "whitelist" they have.
If it works from an internal network, then the problem is most likely not the code. You need to debug it and see what error turns up when running it outside of the network. Then check the logs on the firewall and the target exchange server to see what is happening.
One possible culprit is that the DNS name is not setup outside the office network, or that the office firewall is not setup to pass traffic (or only to pass SMTP traffic) from the internet to the server in question. Another is that Exchange Web Services is not setup properly to accept requests from the outside world. That can be tested from http://www.testexchangeconnectivity.com/.
If this isn't enough for you to get there, post more info about what errors you are seeing. "It isn't working, I want it to work" kind of reminds me of the Star Trek TNG episode about the species who kept telling Geordi to "make it go".
If you are asking if the code works (which it doesn't look like you are but it's in your post) you should ask on stackoverflow. If you are wondering why it won't work from home Its likely because the edge server is not set up to relay, and if you are at home and not vpn'd into the network that's all you have access to.
You need to break this down a bit:
What's the MSExchangeWebServiceURL? I don't need to know your real URL, but is this resolvable from your home network? i.e. is it an internal DNS host (server.mycompany.local) or is it an externally-resolvable DNS host (mail.yourcompany.com)?
If it's internal, like another poster said, you'll at least need to VPN in (or replace that with the external URL).
I'm not a big C# guy, but I'm guessing it's looking for your Exchange Server hostname or FQDN, and since the type is "SMTP" it wants to establish a TCP session with your mail server. You can likely test this out by opening up your command prompt and trying to telnet <MSExchangeWebServiceURL> 25. When that works, my guess is your code will work too.

Categories

Resources