Re: [twsocket] Connecting to a webserver via https...

2018-03-05 Thread Angus Robertson - Magenta Systems Ltd
> try to insert Sleep after SslHttpCli.Get:
> while not terminated do
>   begin
> SslHttpCli.URL := ...
> SslHttpCli.Get;
> Sleep(0/10/50/100/...);
>   end;

Loops are not necessary, ICS is event driven, when one page is received
(OnRequestDone event) you use that to trigger the next GET, with a
windows message.  

Sleep just slows everything down.  

ICS CPU usage will be in DoRequestSync which is called after every sync
request looping the message loop.  But the CPU usage often shown by
tools is not real, it does not slow down other applications.  And ICS
will normally only be using a single thread, and most CPUs now have
four CPUs so never more than 25%.   

Angus

-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Connecting to a webserver via https...

2018-03-05 Thread Shumkin Alexey
Hello,
just a hint

If your loop (with Indy) is the same as you've written
while not terminated do
  begin
SslHttpCli.URL := ...
SslHttpCli.Get;
  end;

then I've run a busy thread and CPU load might be high

try to insert Sleep after SslHttpCli.Get:
while not terminated do
  begin
SslHttpCli.URL := ...
SslHttpCli.Get;
Sleep(0/10/50/100/...);
  end;

and see will CPU load decrease?

As for Overbyte HTTPS client, the only thing I'd propose is to debug
sources ))

2018-03-04 17:29 GMT+03:00 Oliver Dahlmann :

> Hello ICS-Users,
>
> I used Indy-Components for a long time, i stucked when i tried to access an
> AXIS-Camera with a very high resolution. Everything worked fine,
> including access via SSL, but TIdHTTP produced enourmous CPU-Load (One
> Camera-Stream without any processing, only receiving data leads to about
> 12%
> CPU-Load on my i7-7700k).
>
> So i came to ICS and tried it out. With http, i have approx. 0.3% CPU
> Load for the same task. Great. Then I tried to use SSL (ssleay32 and
> libeay32.dll are in its place) and here is where I stuck...
>
> I only receive one packet from the camera saying "// This is the only
> packet we get when trying https:
> //
> //
> //401 Unauthorized
> //
> //Unauthorized
> //This server could not verify that you
> //are authorized to access the document
> //requested.  Either you supplied the wrong
> //credentials (e.g., bad password), or your
> //browser doesn't understand how to supply
> //the credentials required.
> //".
>
> This is my Main-Method:
>
> procedure TTestThread.Execute;
> begin
>   SslHttpCli := TSslHttpCli.Create(nil);
>   SslHttpCli.Username := 'root';
>   SslHttpCli.Password := '1234';
>   SslHttpCli.OnBeforeAuth := SslHttpCliBeforeAuth;
>   SslHttpCli.OnDocData := SslHttpCliDocData;
>
>   SslHttpCli.SslContext := TSslContext.Create(SslHttpCli);
>   SslHttpCli.SslContext.SslMinVersion := sslVerTLS1;
>   SslHttpCli.OnSslVerifyPeer := SslHttpCliSslVerifyPeer;
>   SslHttpCli.OnSslHandshakeDone := SslHttpCliSslHandshakeDone;
>
>   //SslHttpCli.ServerAuth := httpAuthDigest;
>
>   while not terminated do
>   begin
> SslHttpCli.URL := 'https://192.168.56.99/axis-cgi/mjpg/video.cgi';
> // http is working fine, auth is no problem then...
> SslHttpCli.Get;
>   end;
>
>   SslHttpCli.Free;
> end;
>
> and these are the additional methods:
>
> procedure TTestThread.SslHttpCliSslVerifyPeer(Sender: TObject; var Ok:
> Integer; Cert: TX509Base);
> begin
>   // We never get here
>   OK := 0; //??
> end;
>
> procedure TTestThread.SslHttpCliSslHandshakeDone(Sender: TObject;
> ErrCode: Word; PeerCert: TX509Base; var Disconnect: Boolean);
> begin
>   // Here we are 1st
>   // ErrCode is 0
>   Disconnect := FALSE;
> end;
>
> procedure TTestThread.SslHttpCliBeforeAuth(Sender: TObject; AuthType:
> THttpAuthType; ProxyAuth: Boolean; const AuthHdr: string;
>   var Allow: Boolean);
> begin
>   // Here we are 2nd
>   // AuthType is httpAuthDigest
>   // AuthHdr = 'Digest realm="AXIS_ACCC8E1CF5D6",
> nonce="39lra5ZmBQA=8c4897b58b35609ca5635c95d3738bd590a730a6",
> algorithm=MD5, qop="auth"'
>   Allow := TRUE;
> end;
>
>
> Do someone has any idea, what i need to do to establish a SSL-Connection to
> my camera?
>
> Thank you very much for any ideas and hints...
>
> Best regards,
>
> Oliver Dahlmann
>
>
>
>
> --
> To unsubscribe or change your settings for TWSocket mailing list
> please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
> Visit our website at http://www.overbyte.be
>
-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Connecting to a webserver via https...

2018-03-04 Thread Angus Robertson - Magenta Systems Ltd
> If you running in a thread you  have to write a message pump. Now 
> the only thing you do is executing a Get. But this has no 
> difference in http or https.

> > I used Indy-Components for a long time, i stucked when i tried 
> > to access an AXIS-Camera with a very high resolution. 

Indeed, Indy is blocking so you need to use threads all over the place,
whereas ICS is event driven and will handle several hundred
simultaneous sessions in a single thread. At least provided those
connections are not doing other blocking things like writing to a
database. 

The camera says you have an authentication problem, so I'd look at the
code in SslHttpCliBeforeAuth and see how it differs from the non-SSL
version.  

You can also the onCommand event to log what headers are actually being
sent to the camera, I don't understand what you trying to do in
BeforeAuth and it might not be producing the result you expect. 

The latest OverbyteIcsHttpProt in SVN and the overnight zip has a new
HTTP property, ExtraHeaders,to simplify adding extra headers to
a request (previously done using onBeforeHeaderSend event), and that is
specifically for strange authentication purposes like OAuth2. 

Angus



-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be


Re: [twsocket] Connecting to a webserver via https...

2018-03-04 Thread Wilfried Mestdagh
If you running in a thread you  have to write a message pump. Now the 
only thing you do is executing a Get. But this has no difference in http 
or https.


Met vriendelijke groeten,
Wilfried Mestdagh

Op 04-03-18 om 15:29 schreef Oliver Dahlmann:

Hello ICS-Users,

I used Indy-Components for a long time, i stucked when i tried to 
access an

AXIS-Camera with a very high resolution. Everything worked fine,
including access via SSL, but TIdHTTP produced enourmous CPU-Load (One
Camera-Stream without any processing, only receiving data leads to 
about 12%

CPU-Load on my i7-7700k).

So i came to ICS and tried it out. With http, i have approx. 0.3% CPU
Load for the same task. Great. Then I tried to use SSL (ssleay32 and
libeay32.dll are in its place) and here is where I stuck...

I only receive one packet from the camera saying "// This is the only
packet we get when trying https:
//
//
//401 Unauthorized
//
//Unauthorized
//This server could not verify that you
//are authorized to access the document
//requested.  Either you supplied the wrong
//credentials (e.g., bad password), or your
//browser doesn't understand how to supply
//the credentials required.
//".

This is my Main-Method:

procedure TTestThread.Execute;
begin
  SslHttpCli := TSslHttpCli.Create(nil);
  SslHttpCli.Username := 'root';
  SslHttpCli.Password := '1234';
  SslHttpCli.OnBeforeAuth := SslHttpCliBeforeAuth;
  SslHttpCli.OnDocData := SslHttpCliDocData;

  SslHttpCli.SslContext := TSslContext.Create(SslHttpCli);
  SslHttpCli.SslContext.SslMinVersion := sslVerTLS1;
  SslHttpCli.OnSslVerifyPeer := SslHttpCliSslVerifyPeer;
  SslHttpCli.OnSslHandshakeDone := SslHttpCliSslHandshakeDone;

  //SslHttpCli.ServerAuth := httpAuthDigest;

  while not terminated do
  begin
    SslHttpCli.URL := 'https://192.168.56.99/axis-cgi/mjpg/video.cgi';
// http is working fine, auth is no problem then...
    SslHttpCli.Get;
  end;

  SslHttpCli.Free;
end;

and these are the additional methods:

procedure TTestThread.SslHttpCliSslVerifyPeer(Sender: TObject; var Ok:
Integer; Cert: TX509Base);
begin
  // We never get here
  OK := 0; //??
end;

procedure TTestThread.SslHttpCliSslHandshakeDone(Sender: TObject;
ErrCode: Word; PeerCert: TX509Base; var Disconnect: Boolean);
begin
  // Here we are 1st
  // ErrCode is 0
  Disconnect := FALSE;
end;

procedure TTestThread.SslHttpCliBeforeAuth(Sender: TObject; AuthType:
THttpAuthType; ProxyAuth: Boolean; const AuthHdr: string;
  var Allow: Boolean);
begin
  // Here we are 2nd
  // AuthType is httpAuthDigest
  // AuthHdr = 'Digest realm="AXIS_ACCC8E1CF5D6",
nonce="39lra5ZmBQA=8c4897b58b35609ca5635c95d3738bd590a730a6",
algorithm=MD5, qop="auth"'
  Allow := TRUE;
end;


Do someone has any idea, what i need to do to establish a 
SSL-Connection to

my camera?

Thank you very much for any ideas and hints...

Best regards,

Oliver Dahlmann






--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be