Page 1 of 1

Problem with a proxy

Posted: Sun Aug 06, 2023 9:38 am
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?

Re: Problem with a proxy

Posted: Tue Aug 08, 2023 9:48 am
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.

Re: Problem with a proxy

Posted: Wed Aug 09, 2023 12:14 am
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..

Re: Problem with a proxy

Posted: Wed Aug 09, 2023 6:12 am
by dilfich
Try not only to change the user, but also the password.
With one IP but a different user\ password, everything works fine.

Re: Problem with a proxy

Posted: Fri Aug 11, 2023 8:23 am
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;

Re: Problem with a proxy

Posted: Wed Aug 16, 2023 8:57 am
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

Re: Problem with a proxy

Posted: Fri Aug 18, 2023 7:40 am
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

Re: Problem with a proxy

Posted: Tue Aug 22, 2023 1:37 pm
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)

Re: Problem with a proxy

Posted: Fri Aug 25, 2023 9:23 am
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 :)

Re: Problem with a proxy

Posted: Fri Dec 08, 2023 2:33 am
by micmorozov
Try to dynamically create a browser and recreate it every time you change proxy