Autor Beitrag
jackie05
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 357



BeitragVerfasst: Sa 03.10.09 13:24 
Hallo,
ich möchte den Quelltext einer Seite auslesen, welche über eine Sichere Verbindung "SSL" läuft, leider bekomme ich immer diese Fehlermeldung in Delphi angezeigt:

ausblenden Delphi-Quelltext
1:
Erste Gelegenheit für Exception bei $7C812A7B. Exception-Klasse EIdOSSLConnectError mit Meldung 'Error connecting with SSL.'. Prozess Project1.exe (4596)					


Hier ist der Quellcode:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
var
  SSLIOHandler: TIdSSLIOHandlerSocketOpenSSL;
  Quelltext: string;
begin
  SSLIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create;
  HTTP.CookieManager := IdCookieManager1;
  HTTP.IOHandler := SSLIOHandler;
  HTTP.HandleRedirects := true;
  HTTP.Request.UserAgent := 'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10';
  Quelltext := HTTP.Get('https://www.test-seite.com');
  Memo1.Text := Quelltext;
end;


kann mir Vielleicht wer weiter helfen?

Vielen Dank schonmal.

MfG


Zuletzt bearbeitet von jackie05 am Sa 03.10.09 20:44, insgesamt 1-mal bearbeitet
jackie05 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 357



BeitragVerfasst: Sa 03.10.09 20:02 
Ich bin jetzt einwenig weitergekommen.
Ich versuche mich auf einer Seite einzuloggen über SSL und bekomme diese Fehlermeldung:
ausblenden Delphi-Quelltext
1:
Connection Closed Gracefully.					


Hier mal der Code:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
var
  SSLIOHandler: TIdSSLIOHandlerSocketOpenSSL;
  Stream: TIdMultipartFormDataStream;
  Quelltext: string;
begin
  SSLIOHandler := TIdSSLIOHandlerSocketOpenSSL.Create;
  HTTP.CookieManager := IdCookieManager1;
  SSLIOHandler.SSLOptions.CertFile := 'SSL/test.cer';
  SSLIOHandler.SSLOptions.VerifyDepth := 2;
  SSLIOHandler.SSLOptions.Method := sslvSSLv23;
  SSLIOHandler.SSLOptions.Mode := sslmClient;
  HTTP.Request.ContentType := 'application/x-www-form-urlencoded';
  HTTP.HandleRedirects := true;
  HTTP.Request.UserAgent := 'Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.0.10) Gecko/2009042316 Firefox/3.0.10';
  HTTP.ReadTimeout := 5000;
  HTTP.IOHandler := SSLIOHandler;

  Stream := TIdMultipartFormDataStream.Create;
  Stream.AddFormField('_loginUID','jackie05');
  Stream.AddFormField('_loginPWD','********');
  Quelltext := Form1.HTTP.Post('https://www.testseite.com/de/login.aspx?do=login',Stream);
  Form1.Memo1.Text := Quelltext;

  Stream.Free;
end;


Ich habe versucht die Meldung abzufangen, bringt mir aber nix, da die Rückgabe sowieso leer ist im Quelltext.

Was habe ich falsch gemacht?

MfG
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Sa 03.10.09 23:34 
Das ist kein Fehler, sondern nur die Benachrichtigung, dass die Verbindung von der anderen Seite normal beendet wurde.

Bei dir fehlt aber auch komplett die Exceptionbehandlung (try..finally und so), so dass du in Verbindung mit Indy ziemlich sicher Speicherlecks produzierst...
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 04.10.09 02:39 
Wie jaenicke schon gesagt hat, das ist so in Ordnung. Ist nur etwas blöd von den Indys gelöst, eine Exceptions, also einen Ausnahmefehler, zu werfen, wenn alles geklappt hat. Keine Ahnung, warum die das so gemacht haben und nicht ein einfaches Ereignis definiert haben. Aber du bist nicht der erste, der darüber stolpert.
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: So 04.10.09 03:21 
user profile iconLuckie hat folgendes geschrieben Zum zitierten Posting springen:
Wie jaenicke schon gesagt hat, das ist so in Ordnung. Ist nur etwas blöd von den Indys gelöst, eine Exceptions, also einen Ausnahmefehler, zu werfen, wenn alles geklappt hat.

Naja, man versucht Daten zu lesen, obwohl die Verbindung bereits von der Gegenstelle geschlossen wurde. Ist doch (mehr oder weniger) ein Fehler, oder nicht?
Also ich selber finds ok (wenn man es denn weiß :) )

Edit: Ok, man kann drüber streiten, warum nicht einfach das OnDisconnect aufgerufen wurde..

_________________
PROGRAMMER: A device for converting coffee into software.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 04.10.09 04:16 
user profile iconXentar hat folgendes geschrieben Zum zitierten Posting springen:
Naja, man versucht Daten zu lesen, obwohl die Verbindung bereits von der Gegenstelle geschlossen wurde. Ist doch (mehr oder weniger) ein Fehler, oder nicht?
Nein, darum geht es nicht. Diese Exception wird ausgelöst weil die Gegenseite die Verbindung beendet hat. Nicht weil man versucht danach noch zu lesen.

Exceptions sind bei Indy wirklich als Ausnahmen im Programmfluss gedacht, nicht als Fehler.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: So 04.10.09 04:24 
Man könnte jetzt philosophieren, ob es wirklich eine Ausnahme ist, wenn die Gegenstelle die Verbindung beendet. Ich meine, wenn ich telefoniere und der andere Teilnehmer legt auf, nach dem wir uns verabschiedet haben, kann man das ja auch nicht unbedingt als Ausnahme bezeichnen, eher schon als Regel.
Martok
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 3661
Erhaltene Danke: 604

Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
BeitragVerfasst: So 04.10.09 06:19 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Exceptions sind bei Indy wirklich als Ausnahmen im Programmfluss gedacht, nicht als Fehler.

Der war gut ;)
Indy schmeißt für jeden kleinen noch so kleinen Fehler eine Exception. Übrigens auch für jeden HTTP-Statuscode <> 200.

Jedenfalls, zum Connection Closed Gracefully haben die doch extra ganze Romane reinkommentiert, Source lesen hilft:

IdTCPConnection.pas hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
      (* ************************************************************* //
      ------ If you receive an exception here, please read. ----------

      If this is a SERVER
      -------------------
      The client has disconnected the socket normally and this exception is used to notify the
      server handling code. This exception is normal and will only happen from within the IDE, not
      while your program is running as an EXE. If you do not want to see this, add this exception
      or EIdSilentException to the IDE options as exceptions not to break on.

      From the IDE just hit F9 again and Indy will catch and handle the exception.

      Please see the FAQ and help file for possible further information.
      The FAQ is at http://www.nevrona.com/Indy/FAQ.html

      If this is a CLIENT
      -------------------
      The server side of this connection has disconnected normaly but your client has attempted
      to read or write to the connection. You should trap this error using a try..except.
      Please see the help file for possible further information.

      // ************************************************************* *)

_________________
"The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: So 04.10.09 11:42 
Richtig, im Quelltext steht einiges. Und dann steht hier auch noch etwas dazu:
www.delphipraxis.net...st122870.html#122870 hat folgendes geschrieben:
Diese Exception im original Source der INDY's zu kapseln oder zu entfernen ist eine ziemlich schlechte Idee, sie erfüllt nämlich eine sehr wichtige Aufgabe. Nur, das was du begreifen musst ist WAS die Indy Programmier unter einer Exception verstehen ! Wir gehen nur davon aus das Exception Fehler im programfluß sind, nun die Indy Programmierer sehen eine Exception als Außnahmebedingung also nicht unbedingt als Fehler im Programfluß. Diese Sichtweise ist sehr umstritten und ärgert viele Programmiere am Indy Konzept, aber man kan sich daran gewöhnen.

[...]