Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delphi Error "connection closed gracefully" 3

Status
Not open for further replies.

marieannie

Programmer
Jan 14, 2004
84
US
Hello, I'm trying to send an email using delphi win32
but it is giving me this error:
"connection closed gracefully"

any suggestions how to ignore this exception??

Regards
MA
 
The error message indicates that a remote connection was closed without your request, but that it hasn't caused any problems - ie. both clients have finished talking.

Usually, it means you forgot to do a MyIndyControl.Disconnect after you had finished talking to the remote client, or whatever method is equivalent for the class you're using.
 
Hello, sorry to reply until now....

Here is the code..
Code:
fMain.SMTP1.Disconnect;
        fMain.SMTP1.Connect;
        fMain.MailMessage.Body.Clear;
        fMain.MailMessage.From.Address := 'email@domain.com';
        Datos.qClienteContacto.SQL.Clear;
        xEmailAddresses:='';
       While Not Datos.qClienteContacto.eof do
        begin
              if xEmailAddresses='' then
                    xEmailAddresses:=trim(Datos.qClienteContactoEmailContacto.AsString)
              else
                    xEmailAddresses:=xEmailAddresses+', '+trim(Datos.qClienteContactoEmailContacto.AsString);
              Datos.qClienteContacto.Next;
        end;
        fMain.MailMessage.Recipients.EMailAddresses := xEmailAddresses;
          fMain.MailMessage.ContentType := 'text/html';
        fMain.MailMessage.Subject := 'Notificacion de Recepcion de Mercancia del Trafico:'+Datos.qTrafAABTrTrafico.AsString;
        fMain.MailMessage.Body.Add('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd">');[/URL]
        fMain.MailMessage.Body.Add('<html>');
        fMain.MailMessage.Body.Add('<head>');
        fMain.MailMessage.Body.Add('<title>Notificacion de Arribo</title>');
        fMain.MailMessage.Body.Add('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">');
        fMain.MailMessage.Body.Add('</head>');

        fMain.MailMessage.Body.Add('<link rel="stylesheet" href="[URL unfurl="true"]http://www.domain.com/iaadc/estilo.css"[/URL] type="text/css">');
        fMain.MailMessage.Body.Add('<body>');

        fMain.MailMessage.Body.Add('<table width="50%" border="0" cellpadding="0" cellspacing="0" bordercolor="#000066">');
        fMain.MailMessage.Body.Add('<tr>');
	      fMain.MailMessage.Body.Add('<td class="titulogeneral">');
	      fMain.MailMessage.Body.Add('<img src="[URL unfurl="true"]http://www.domain.com/iaadc/logo.jpg">');[/URL]
	      fMain.MailMessage.Body.Add('</td>');
        fMain.MailMessage.Body.Add('</tr>');
        fMain.MailMessage.Body.Add('<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#000066">');
        fMain.MailMessage.Body.Add('<tr>');
	      fMain.MailMessage.Body.Add('<td class="titulogeneral">');
	      fMain.MailMessage.Body.Add('COMPANY, INC.');
	      fMain.MailMessage.Body.Add('</td>');
        fMain.MailMessage.Body.Add('</tr>');
        fMain.MailMessage.Body.Add('</TABLE>');

        fMain.MailMessage.Body.Add('<td colspan="4"><!-- BEGIN HEADER -->');
        fMain.MailMessage.Body.Add('<table cellpadding="0" cellspacing="0" border="0" style="padding: 0px; margin: 0px;">');
        fMain.MailMessage.Body.Add('<tr>');
        fMain.MailMessage.Body.Add('<td><img');
        fMain.MailMessage.Body.Add('src="[URL unfurl="true"]http://www.domain.com/iaadc/banner_fwd_infoembarque.gif"');[/URL]
        fMain.MailMessage.Body.Add('width="550" height="25" border="0" alt="Informacion de Embarque">');
        fMain.MailMessage.Body.Add('</td>');
        fMain.MailMessage.Body.Add('</tr>');
        fMain.MailMessage.Body.Add('</table>');
        fMain.MailMessage.Body.Add('<!-- END HEADER --></td>');
        fMain.MailMessage.Body.Add('<tr>');
        fMain.MailMessage.Body.Add('<td>');
       fMain.MailMessage.Body.Add('<table width="100%" border="1" cellpadding="0" cellspacing="0">');
       fMain.MailMessage.Body.Add('<tr>');
       fMain.MailMessage.Body.Add('<td class="botonesmenu">');
       fMain.MailMessage.Body.Add('Linea Flete:');
       fMain.MailMessage.Body.Add('</td>');
       fMain.MailMessage.Body.Add('<td class="botonesmenu">');
       fMain.MailMessage.Body.Add(Datos.tTrnUSAtrnUSNOMBRE.AsString);
       fMain.MailMessage.Body.Add('</td>');
       fMain.MailMessage.Body.Add('<td class="botonesmenu">');
       fMain.MailMessage.Body.Add('Fecha:');
       fMain.MailMessage.Body.Add('</td>');
      fMain.MailMessage.Body.Add('<td class="botonesmenu">');
      fMain.MailMessage.Body.Add(DateToStr(Datos.qTrafAABTrFrecep.AsDateTime));
      fMain.MailMessage.Body.Add('</td>');
	
        fMain.MailMessage.Body.Add('</tr>');

        fMain.MailMessage.Body.Add('</table>');


        fMain.MailMessage.Body.Add('</body>');
        fMain.MailMessage.Body.Add('</html>');

       fMain.SMTP1.Send(fMain.MailMessage);
      fMain.SMTP1.Disconnect;
apparently the message appears when is executed the instruction
fmain.smtp1.send(fmain.mailmessage)
or when disconnect
fmain.smtp1.disconnect

Any suggestions How to fix it??

Regards,
Ana
 
are you getting this exception outside delphi? (ie when you run the executable without delphi)

This is normal behaviour. The makers of the indy components implemented an exception to inform the other components that the socket has been closed. you can turn of this exception within delphi so that you never get this message.

look at the debugger options.

/Daddy


-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Yes I'm getting the exception outside (executable) and also using delphi (debugging)

I add some exceptions type to ignore in the debugger options. but still receiving the message...
I don't know if I'm using the correct exception...


Regards
AG


 
is this Indy 9 you are using?

you can solve this problem by masking the exception

Code:
 ...
  try
   fMain.SMTP1.Send(fMain.MailMessage);
   fMain.SMTP1.Disconnect;
  except
   on E : Exception do
    if E <> EIdConnClosedGracefully then
     raise
  end

for more info about this exception (it is really not an error) look here:
/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
I'm using the component TIdSMTP (part of the IndyClients)

I try your suggestion but
is giving me the following error:

E2003 UNDECLARED IDENTIFIER: 'EIdConnClosedGraceFully'

i have this exception in my ignore list...
but is not working...

Regards,
Ana

 
Now is giving me the following error:
E2015 operator not applicable to this operand type

when
Code:
if E <> EIdConnClosedGracefully then
                 raise

any suggestions?
MA
 
Hello, I finally found what was the problem
I changed
Code:
if E <> EIdConnClosedGracefully then
                 raise

with this code:
Code:
if E is EIdConnClosedGracefully then
else
  raise

Apparently it is working..
Thank you so much for your help.

MA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top