Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.

Problem with a proxy

Post Reply
madvet
Posts: 8
Joined: Fri Aug 19, 2022 11:48 am

Problem with a proxy

Post by madvet »

I am setting up a proxy:

Code: Select all

procedure TMainForm.Proxy1ButtonClick(Sender: TObject);
begin
 ChromiumWindow1.ChromiumBrowser.ProxyType := CEF_PROXYTYPE_FIXED_SERVERS;
 ChromiumWindow1.ChromiumBrowser.ProxyServer := 'proxy.host';
 ChromiumWindow1.ChromiumBrowser.ProxyPort := 8000;
 ChromiumWindow1.ChromiumBrowser.ProxyUsername := '1000+US+10-1'; // "1" is the session, it generates a new proxy
 ChromiumWindow1.ChromiumBrowser.ProxyPassword := 'ThePassword';
 ChromiumWindow1.ChromiumBrowser.ProxyScheme := psHTTP;
 ChromiumWindow1.ChromiumBrowser.UpdatePreferences;

 ChromiumWindow1.ChromiumBrowser.LoadURL('http://checkip.dyndns.org/'); // Here is IP 1
end;
Then I am trying to change a proxy:

Code: Select all

procedure TMainForm.Proxy2ButtonClick(Sender: TObject);
begin
 ChromiumWindow1.ChromiumBrowser.ProxyType := CEF_PROXYTYPE_FIXED_SERVERS;
 ChromiumWindow1.ChromiumBrowser.ProxyServer := 'proxy.host';
 ChromiumWindow1.ChromiumBrowser.ProxyPort := 8000;
 ChromiumWindow1.ChromiumBrowser.ProxyUsername := '1000+US+10-2'; // "2" is the session, it generates another proxy
 ChromiumWindow1.ChromiumBrowser.ProxyPassword := 'ThePassword';
 ChromiumWindow1.ChromiumBrowser.ProxyScheme := psHTTP;
 ChromiumWindow1.ChromiumBrowser.UpdatePreferences;

 ChromiumWindow1.ChromiumBrowser.LoadURL('http://checkip.dyndns.org/'); // Here is also IP 1?
end;
If I restart the application, then the proxy 2 works correctly.
Is it possible to change proxy without restart?
User avatar
salvadordf
Posts: 4056
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: Problem with a proxy

Post by salvadordf »

Hi,

This seems to be an issue in Chromium but I would try to :
  • Update the proxy settings with ProxyType := CEF_PROXYTYPE_DIRECT
  • Navigate to some random website.
  • Update the proxy settings with the '1000+US+10-2' username, ProxyType := CEF_PROXYTYPE_FIXED_SERVERS, etc.
madvet
Posts: 8
Joined: Fri Aug 19, 2022 11:48 am

Re: Problem with a proxy

Post by madvet »

salvadordf wrote: Tue Aug 08, 2023 9:48 am Hi,

This seems to be an issue in Chromium but I would try to :
  • Update the proxy settings with ProxyType := CEF_PROXYTYPE_DIRECT
  • Navigate to some random website.
  • Update the proxy settings with the '1000+US+10-2' username, ProxyType := CEF_PROXYTYPE_FIXED_SERVERS, etc.
It doesn't help..
dilfich
Posts: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Problem with a proxy

Post by dilfich »

Try not only to change the user, but also the password.
With one IP but a different user\ password, everything works fine.
madvet
Posts: 8
Joined: Fri Aug 19, 2022 11:48 am

Re: Problem with a proxy

Post by madvet »

dilfich wrote: Wed Aug 09, 2023 6:12 am Try not only to change the user, but also the password.
With one IP but a different user\ password, everything works fine.
I don't know how it can works fine :)

Code: Select all

procedure TMainForm.Proxy1ButtonClick(Sender: TObject);
begin
 ChromiumWindow1.ChromiumBrowser.ProxyType := CEF_PROXYTYPE_FIXED_SERVERS;
 ChromiumWindow1.ChromiumBrowser.ProxyServer := 'proxy.host';
 ChromiumWindow1.ChromiumBrowser.ProxyPort := 8000;
 ChromiumWindow1.ChromiumBrowser.ProxyUsername := '1000+US+10-1'; // "1" is the session, it generates a new proxy
 ChromiumWindow1.ChromiumBrowser.ProxyPassword := 'ThePassword';
 ChromiumWindow1.ChromiumBrowser.ProxyScheme := psHTTP;
 ChromiumWindow1.ChromiumBrowser.UpdatePreferences;

 ChromiumWindow1.ChromiumBrowser.LoadURL('http://checkip.dyndns.org/'); // Here is IP 1
end;

procedure TMainForm.Proxy2ButtonClick(Sender: TObject);
begin
 ChromiumWindow1.ChromiumBrowser.ProxyType := CEF_PROXYTYPE_FIXED_SERVERS;
 ChromiumWindow1.ChromiumBrowser.ProxyServer := 'proxy.host';
 ChromiumWindow1.ChromiumBrowser.ProxyPort := 8000;
 ChromiumWindow1.ChromiumBrowser.ProxyUsername := '1000+US+10-2'; // here is another user name
 ChromiumWindow1.ChromiumBrowser.ProxyPassword := 'ThePassword1'; // here is another password
 ChromiumWindow1.ChromiumBrowser.ProxyScheme := psHTTP;
 ChromiumWindow1.ChromiumBrowser.UpdatePreferences;

 ChromiumWindow1.ChromiumBrowser.LoadURL('http://checkip.dyndns.org/'); // Here is also IP 1 with wrong password
end;
dilfich
Posts: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Problem with a proxy

Post by dilfich »

You can try it again before changing the proxy.

Code: Select all

  TempCallback : ICefCompletionCallback;
   .....
  TempCallback := TCefCloseAllConnectionsCompletionCallback.Create(nil);
  TempContext[FCefID].CloseAllConnections(TempCallback);
or something like that
madvet
Posts: 8
Joined: Fri Aug 19, 2022 11:48 am

Re: Problem with a proxy

Post by madvet »

dilfich wrote: Wed Aug 16, 2023 8:57 am You can try it again before changing the proxy.

Code: Select all

  TempCallback : ICefCompletionCallback;
   .....
  TempCallback := TCefCloseAllConnectionsCompletionCallback.Create(nil);
  TempContext[FCefID].CloseAllConnections(TempCallback);
or something like that
I am trying this:

Code: Select all

 ChromiumWindow1.ChromiumBrowser.CloseAllConnections(false);
It is not working also
dilfich
Posts: 330
Joined: Thu Nov 30, 2017 1:17 am

Re: Problem with a proxy

Post by dilfich »

It is difficult to find a solution without having problematic proxies.
Another option is proxification.
For example - Synapse\demo\httpproxy
Only by correcting and instead of directly connecting to Sock, add the necessary proxy, and the browser will be permanent.

Crooked) but as an option and quite working, complexity can only cause multithreading. :D

something like that..

Code: Select all

//core of proxy
procedure TTCPHttpThrd.Execute;
var
.................
begin
  idstr:= inttostr(self.handle) + ' ';
  Sock:= TTCPBlockSocket.create;
  Qsock:= TTCPBlockSocket.create;
  try
    Sock.socket:= FCsock;

    repeat
      ............... Proxy

      qSock.SocksType := ST_Socks5;
      qSock.SocksIP:= HostU1;
      qSock.SocksPort:= PortU1;
      qSock.SocksUsername:= UserU1;
      qSock.SocksPassword:= PassU1;

      qSock.SocksResolver:= False;
      qSock.InterPacketTimeout:= False;
      qSock.SocksTimeout:= 15000;
      qSock.SetTimeout(15000);

      Sock.SocksType := ST_Socks5;
      Sock.SocksIP:= HostU1;
      Sock.SocksPort:= PortU1;
      Sock.SocksUsername:= UserU1;
      Sock.SocksPassword:= PassU1;

      Sock.SocksResolver:= False;
      Sock.InterPacketTimeout:= False;
      Sock.SocksTimeout:= 15000;
      Sock.SetTimeout(15000);


      //read request line
      Headers.Clear;
      ProxyHeaders.Clear;
      proxykeep := false;
      LogRec.ip := sock.GetRemoteSinIP;
      repeat
but there is still somewhere you need to disconnect the connection before changing the proxy. but this is not a browser, you can figure it out)
madvet
Posts: 8
Joined: Fri Aug 19, 2022 11:48 am

Re: Problem with a proxy

Post by madvet »

dilfich wrote: Tue Aug 22, 2023 1:37 pm It is difficult to find a solution without having problematic proxies.
Another option is proxification.
For example - Synapse\demo\httpproxy
Only by correcting and instead of directly connecting to Sock, add the necessary proxy, and the browser will be permanent.

Crooked) but as an option and quite working, complexity can only cause multithreading. :D

something like that..
Thank you for the idea! I don't want to use synapse - I'll try to do it with Indy :)
micmorozov
Posts: 18
Joined: Mon Oct 07, 2019 7:53 am

Re: Problem with a proxy

Post by micmorozov »

Try to dynamically create a browser and recreate it every time you change proxy
Post Reply