?
Solved

Test if proxy server is ok.

Posted on 2006-11-09
12
Medium Priority
?
2,028 Views
Last Modified: 2008-03-15
Hi,

I need a way of testing if a proxy is working or it's stopped/not available, etc.

Thank you!
0
Comment
Question by:crystyan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
12 Comments
 
LVL 13

Expert Comment

by:BlackTigerX
ID: 17911293
what defines if it's "ok"?
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 17911956
Most proxy servers use port 8080 so we will assume 8080. If something non standard then substitute your proxy's port.

Anyway, in Delphi 5, a component is available called ClientSocket. An Indy alternative "might" be the idTCPClient. Haven't tested it but should be similar if you do not use D5.

Anyway, just set your port and your proxy's IP, make the component active and respond to the events OnConnect OnError and OnDisconnect.

If you connect, all "should" be active as far as the proxy port and communication. If error, then it is dead..

Good luck and hope this helped.

JJ
0
 

Author Comment

by:crystyan
ID: 17914562
Johnjces where should I put the proxy address and port ? I have idTCPClient

Thanks
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 18

Expert Comment

by:Johnjces
ID: 17919795
Try this:

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
  IdTCPClient;

type
  TForm1 = class(TForm)
    Button1: TButton;
    IdTCPClient1: TIdTCPClient;
    procedure IdTCPClient1Connected(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure IdTCPClient1Status(ASender: TObject;
      const AStatus: TIdStatus; const AStatusText: String);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.IdTCPClient1Connected(Sender: TObject); //On connect event. If good do stuff here.
begin
 ShowMessage('Connected!');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
IdTCPClient1.Host := 'Your Proxys IP)
IdTCPClient1.Port := 8080
 try
  IdTCPClient1.Connect(1000);
   except on E:exception do
    begin
     showmessage('Dead');
     // other stuff you might want to do.
    end;
 end;
end;

procedure TForm1.IdTCPClient1Status(ASender: TObject;   // Informational.
  const AStatus: TIdStatus; const AStatusText: String);
begin
 ShowMessage(AStatusText);
end;

end.

Since there is no OnError in the Indy comp we must trap the error if it is dad, it being your proxy.

Let me know.

John
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 17919807
Also, don't forget to disconnect after a successful connect.

such as the following in the button

procedure TForm1.Button1Click(Sender: TObject);
begin
 IdTCPClient1.Host := '192.168.0.20';
 IdTCPClient1.Port := 80;
 try
  IdTCPClient1.Connect(1000);
   except on E:exception do
    showmessage('Bad stuff');
 end;
 IdTCPClient1.Disconnect;
end;
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 17924145
Did I help you?

JJ
0
 

Author Comment

by:crystyan
ID: 17924773
yeah, but I'm still making tests ... it's weird because either all my proxies don't work, either it works only the port 80 to test ...
0
 
LVL 18

Expert Comment

by:Johnjces
ID: 17927254
A thought came to mind. A proxy server forwards all http port 80 and others like ftp ports and stuff on. So, when  trying to connect to it via port 8080 it will want to forward that request on to somewhere beyond the proxy!

So, you could test your proxy by connecting to a web server like google. If that works and you connect, then the proxy is working.

JJ
0
 

Author Comment

by:crystyan
ID: 17927301
what do you mean ?
0
 
LVL 18

Accepted Solution

by:
Johnjces earned 2000 total points
ID: 17927620
From a PC that is using the proxy server, or whatever PC you are using to check your proxy server, you set this PC up to go through the proxy. Then you simply check for connectivity to some web site through the proxy you are wanting to monitor. Simply change your port and IP to say google.com on the TIdTCPClient component. You see, if the proxy is down, you won't be able to connect.

Since the proxy wants to proxy port 8080 to the web on port 80, when you try to test the proxy using port 8080 it wants to proxy it to port 80 somewhere.

Anyway, just a thought.

Good luck!

JJ
0
 
LVL 1

Expert Comment

by:Computer101
ID: 21133157
Forced accept.

Computer101
EE Admin
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month9 days, 14 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question