🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.cppbuilder.internet.socket
5 messages
5 total messages Started by Holger Wiebrock Tue, 29 May 2007 13:17
Proxy server
#1133
Author: Holger Wiebrock
Date: Tue, 29 May 2007 13:17
39 lines
2182 bytes
Hi

i am using the TIdHttp class to communicate with a webserver for exchanging 
some data.

One of our customers uses a proxyserver and i try to setup a connection. 
Unfortunetly i don't get this to work. Neither with indy8 nor indy9 i could 
setup this connection to the proxyserver.

I am using BCB5:

Indy 8 Code:
TIdHTTP *http = new TIdHTTP(0);
http->Request->ProxyServer = "server";
http->Request->ProxyPort = "80";
http->Request->ProxyUsername = "user";
http->Request->ProxyPassword = "password";
AnsiString response = http->Get(some url);

Here i get an error 407 proxy authentication required.
I wrote a testapplication with c# to check the right username and password . 
With .Net i got it to work, so the username and password which i got from 
the admin is correct and the error by indy makes for me no sense at all.

Indy 9 Code:
TIdHTTP *http = new TIdHTTP(0);
http->ProxyParams->ProxyServer = "server";
http->ProxyParams->ProxyPort = "80";
http->ProxyParams->ProxyUsername = "user";
http->ProxyParams->ProxyPassword = "password";
AnsiString response = http->Get(some url);

With indy9 immediatley after the "get" to the specified url i get an access 
violation.
Any ideas would be appreciated because i don't have any other alternative 
than indy.

Greetings from Germany
Holger 
Re: Proxy server
#1034
Author: emerson.pardo
Date: Tue, 29 May 2007 14:42
12 lines
1365 bytes
Hi Holger,

> Indy 9 Code:
> ..
> http->ProxyParams->ProxyPort = "80";

ProxyPort is an int type so the correct code is:

http->ProxyParams->ProxyPort = 80;

[]s
Emerson
Re: Proxy server
#1035
Author: Remy Lebeau (TeamB)
Date: Tue, 29 May 2007 17:17
35 lines
2235 bytes
"Holger Wiebrock" <hw@medata.de> wrote in message
news:465c26d6@newsgroups.borland.com...

> One of our customers uses a proxyserver and i try to setup a
connection.

You did not say what kind of proxy is being using.  It makes a
difference, as there are two different ways to approach it.  What you
have attempted so far only applies to proxies that are specific to the
HTTP protocol.  General TCP proxies, such as a SOCKS server, requires
the use of a separate component, such as TIdSocksInfo, that is to be
attached to the TIdHTTP component via IOHandler.SocksInfo property.

> AnsiString response = http->Get(some url);
>
> Here i get an error 407 proxy authentication required.

Double-check that your proxy username/password are actually correct.
In Indy 9, TIdHTTP also has OnSelectProxyAuthorization and
OnProxyAuthorization events that deal with proxy connections.  And
make sure that the AuthRetries property is set to a reasonable number,
and that you have hoInProcessAuth set in the Options property.

> I wrote a testapplication with c# to check the right username and
password .
> With .Net i got it to work, so the username and password which i got
from
> the admin is correct and the error by indy makes for me no sense at
all.

Please show the .NET code that works for you.


Gambit
Re: Proxy server
#1036
Author: Holger Wiebrock
Date: Wed, 30 May 2007 14:28
80 lines
3701 bytes
Hi Remy

thank you for your answer.

First of all it is a http proxyserver which my customer is using and it is 
still not working.

Today i checked again the credentials and they are correct.

--> My .Net Code:
            try
            {
                NetworkCredential creds = new NetworkCredential("username", 
"password");
                WebRequest req = WebRequest.Create("some url");
                req.Proxy = new WebProxy("server:port");
                req.Proxy.Credentials = creds;
                StreamReader responseReader = new 
StreamReader(req.GetResponse().GetResponseStream());
                Console.WriteLine(responseReader.ReadToEnd());
                responseReader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

My Steps today:

1. Get the latest version 9 Snapshot from indy website.
2. Set hoInProcessAuth
3. After settting ProxyParams.BasicAuthentication "true" i do not get any 
violation errors anymore.
4. Set AuthEntries = 5 although default value 3 supposed to be work.
5. After all now i use OnProxyAuthorization to set the username, password 
and "handled=true"

I still get the error 407.

Greetings Holger

"Remy Lebeau (TeamB)" <no.spam@no.spam.com> schrieb im Newsbeitrag 
news:465c60b9$1@newsgroups.borland.com...
>
> "Holger Wiebrock" <hw@medata.de> wrote in message
> news:465c26d6@newsgroups.borland.com...
>
>> One of our customers uses a proxyserver and i try to setup a
> connection.
>
> You did not say what kind of proxy is being using.  It makes a
> difference, as there are two different ways to approach it.  What you
> have attempted so far only applies to proxies that are specific to the
> HTTP protocol.  General TCP proxies, such as a SOCKS server, requires
> the use of a separate component, such as TIdSocksInfo, that is to be
> attached to the TIdHTTP component via IOHandler.SocksInfo property.
>
>> AnsiString response = http->Get(some url);
>>
>> Here i get an error 407 proxy authentication required.
>
> Double-check that your proxy username/password are actually correct.
> In Indy 9, TIdHTTP also has OnSelectProxyAuthorization and
> OnProxyAuthorization events that deal with proxy connections.  And
> make sure that the AuthRetries property is set to a reasonable number,
> and that you have hoInProcessAuth set in the Options property.
>
>> I wrote a testapplication with c# to check the right username and
> password .
>> With .Net i got it to work, so the username and password which i got
> from
>> the admin is correct and the error by indy makes for me no sense at
> all.
>
> Please show the .NET code that works for you.
>
>
> Gambit
>
> 
Re: Proxy server
#1037
Author: Remy Lebeau (TeamB)
Date: Wed, 30 May 2007 17:00
12 lines
1212 bytes
"Holger Wiebrock" <hw@medata.de> wrote in message
news:465d88d1$1@newsgroups.borland.com...

> I still get the error 407.

Then you need to look at the actual HTTP traffic with a packet sniffer
to see what is different between what WebRequest is transmitted versus
what TIdHTTP is transmitting.


Gambit
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads