Using bugreport-upload via http and proxy

delphi package - automated exception handling
Post Reply
Chris08
Posts: 26
Joined: Wed Mar 01, 2006 3:13 pm
Contact:

Using bugreport-upload via http and proxy

Post by Chris08 »

Hello,

I want to use MadExcept in a corporate environment where internet access is only available via http proxy. How do I configure MadExcept to use proxy settings? - I suspect it doesn't get the IE proxy settings as the bugreports never find a way on my server (they do on in my proxyless environment at home).

Thank you in advance for your advice and suggestions
Chris
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

madExcept is using this function to ask the OS' proxy server. Does that yield the correct results on your PC?

Code: Select all

    function GetProxyServer : string;
    type TInternetProxyInfo = record
           accessType  : dword;
           proxy       : pchar;
           proxyBypass : pchar;
         end;
    const INTERNET_OPTION_PROXY = 38;
          PROXY_TYPE_PROXY      = 2;
    var iqo : function (internet, option: dword; buf: pointer; var bufLen: dword) : bool; stdcall;
        c1  : dword;
        ipi : ^TInternetProxyInfo;
    begin
      result := '';
      iqo := GetProcAddress(LoadLibrary('wininet.dll'), 'InternetQueryOptionA');
      if @iqo <> nil then begin
        c1 := 0;
        iqo(0, INTERNET_OPTION_PROXY, nil, c1);
        if c1 > 0 then begin
          ipi := pointer(LocalAlloc(LPTR, c1));
          if iqo(0, INTERNET_OPTION_PROXY, ipi, c1) then
            result := ipi.proxy;
          LocalFree(dword(ipi));
        end;
      end;
    end;
Chris08
Posts: 26
Joined: Wed Mar 01, 2006 3:13 pm
Contact:

Post by Chris08 »

Thank you for the quick reply. The function returns the currect result for the proxy server. I conclude the cause of the this might be different :?
I have enabled the manual dialog in MadExcept and if I click on the send bug report Icon, I get the following message: "Sorry, sending the bug report didn't work."
I have disabled authentication on my server, but it still refuses to work. However, manually Invoking the script on the server in IE works without problems. Again if I invoke my application from my home computer it works flawlessly.

Any hints would be greatly appreciated
Chris
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Hmmmm... Can you please try this logger to see whether madExcept even tries to send out data to your webserver?

http://www.blad3.ro/
Chris08
Posts: 26
Joined: Wed Mar 01, 2006 3:13 pm
Contact:

Post by Chris08 »

Hello,
indeed, I get a rather strange result:
the log reads as follows:

Code: Select all

project1.exe, size=0, sock=0, proto=tcp, remIP=, remPort=, oper=GetHostByName
Maybe MadExcept fails to resolve my server? I will try now to put in the ip adress directly.
I will keep you posted
Chris
Chris08
Posts: 26
Joined: Wed Mar 01, 2006 3:13 pm
Contact:

Post by Chris08 »

Hello,
I get the same result even if I put the ip addresse in the MadExcept Wizard.
Chris
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Do you have the source code? If so, would you mind stepping through the code to find out what's going wrong? The problem is that I can't reproduce the problem here.

In order to be able to step through the code you have to do this:

(1) Copy madExcept.pas and mad.inc to your project directory.
(2) Edit mad.inc, change "{$D-}{$L-}" to "{$D+}{$L+}".
(3) Recompile.

Now you should be able to set breakpoints in madExcept.pas and browse through it line by line with the debugger.

Please don't forget to remove madExcept.pas and madExcept.dcu from your project folder, when you're done with debugging.

Thanks!!
Chris08
Posts: 26
Joined: Wed Mar 01, 2006 3:13 pm
Contact:

Post by Chris08 »

I just registered MadExcept earlier today, so I guess I will have access to the source soon ;)
I will try to find out what's going on tomorrow.
I'll post again as soon as I know more.
Chris
Chris08
Posts: 26
Joined: Wed Mar 01, 2006 3:13 pm
Contact:

Some more testing

Post by Chris08 »

I have done some testing and debugging:
First I have installed a proxy server (Internet Junkbuster 2.0) on my home-network and set up IE on my development machine to use it. Now I experience the same difficulties with MadExcept in my application: If I try to send a bugreport via http, I get a messagebox that says "Sorry,sending the bugreport didn't work."

Debugging into madexept I find the following: In madexcept.pas the problems lies somewhere in the function ConnectToServer (line 6070 ff): The variable server contains the address of my proxyserver ("my-server:8080"). The value returned for addr in line 6079 is -1. GetHostByName in 6081 returns nil, so addr doesn't get a new value and stays -1. Thus the block starting 6085 never gets invoked and the result of the function is false.

Again I get the same behaviour using a proxy server in the corporate environment of the company I work for and in my home network if I use the proxy server I set up. Without proxyserver it works fine.
I hope this is helpful to you.
Thanks in advance
Chris
Chris08
Posts: 26
Joined: Wed Mar 01, 2006 3:13 pm
Contact:

Post by Chris08 »

Hello,

I have not been able to fix the problem from within MadExcept.pas so far. I think I will work around this using the indy components. I have just played around with those a little and can access my server via proxy without problems even from within the corporate network.

Does MadExcept provide a plugin mechanism for sending bug reports (so that I would not have to hardcode it into MadExcept.pas) myself?

Thank you
Chris
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

I think I've solved the problem. madExcept didn't understand the "serverName:portNumber" logic. In madExcept.pas please use the following code:

Code: Select all

    procedure RemoveProtocol(var str: string);
    var i1 : integer;
    begin
      i1 := PosText('://', str);
      if i1 > 0 then
        Delete(str, 1, i1 + 2);
      i1 := PosText('http=', str);
      if i1 > 0 then begin
        Delete(str, 1, i1 + 4);
        str := SubStr(str, 1, ' ');
      end;
    end;

Code: Select all

    server := GetProxyServer;
    if server <> '' then begin
      RemoveProtocol(server);
      s2 := SubStr(server, 2, ':');
      if s2 <> '' then begin
        i1 := StrToIntEx(false, pchar(s2), Length(s2));
        if i1 <> -1 then begin
          server := SubStr(server, 1, ':');
          port := i1;
        end;
      end;
      site := httpUrl;
    end else
      server := host;
Chris08
Posts: 26
Joined: Wed Mar 01, 2006 3:13 pm
Contact:

Post by Chris08 »

Hello,

your solution works like a charm!
Thank you - great support.

Chris
madshi
Site Admin
Posts: 10764
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

Thanks for reporting the bug and helping to debug it... :)
Post Reply