Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

tcllib smtp problem: read from server timed out

71 views
Skip to first unread message

jfon...@free.fr

unread,
Oct 19, 2006, 4:15:50 AM10/19/06
to
smtp::sendmessage on localhost gives me the following error sometimes:
"SMTP error: read from server timed out"
on sendmail's side:
# tail -f /var/log/maillog
...
Oct 19 10:08:16 stats sendmail[19591]: k9J84Tsn019591:
localhost.localdomain [127.0.0.1] did not issue MAIL/EXPN/VRFY/ETRN
during connection to MTA
...

That seems to happen on high CPU load (1 among 4 though) but works most
of the time.
What could I do to debug the matter?
Thanks for your help!

JL

Pat Thoyts

unread,
Oct 19, 2006, 4:30:30 AM10/19/06
to
jfon...@free.fr writes:

Add -debug 1 to the list of options given to smtp::sendmessage. This
will dump out the SMTP transactions to stdout.

--
Pat Thoyts http://www.patthoyts.tk/
To reply, rot13 the return address or read the X-Address header.
PGP fingerprint 2C 6E 98 07 2C 59 C8 97 10 CE 11 E6 04 E0 B9 DD

jfon...@free.fr

unread,
Oct 19, 2006, 4:59:49 AM10/19/06
to
Pat Thoyts wrote:

> Add -debug 1 to the list of options given to smtp::sendmessage. This
> will dump out the SMTP transactions to stdout.

I did and it did not help. The problem is at:

proc ::smtp::initialize {args} {
...
if {[set code [catch {
set state(sd) [socket -async $server $port]
fconfigure $state(sd) -blocking off -translation binary
fileevent $state(sd) readable [list ::smtp::readable
$token]
} result]]} {
puts stderr "$server: $result"
set ecode $errorCode
set einfo $errorInfo

catch { close $state(sd) }
continue
}
...
(the puts stderr is mine, which gives "read from server timed out")

JL

Pat Thoyts

unread,
Oct 19, 2006, 6:06:04 AM10/19/06
to
jfon...@free.fr writes:

My understanding of this would be that a DNS error occurred as all the
connection stuff should be happening asynchronously. Can you raise
this as a tcllib bug on SourceForge and see if a minimal async
connection script that just connects to the server then issues a QUIT
also errors.
Please include your platform details and the tcl version. Also if this
is intermittent or not and if you use telnet $smtphost 25 do you
connect ok.
FWIW I know some windows virus checkers redirect outgoing port 25 to
a local forwarder so that they can scan sent mail. You might also want
to see if you can use the submission port (587) to send mail instead
of 25.

jfon...@free.fr

unread,
Oct 19, 2006, 7:01:56 AM10/19/06
to
> My understanding of this would be that a DNS error occurred as all the
> connection stuff should be happening asynchronously.
I doubt it since the server is "localhost".

> Can you raise
> this as a tcllib bug on SourceForge and see if a minimal async
> connection script that just connects to the server then issues a QUIT
> also errors.

This will be difficult since it happens only within a big application
(moomps) and only when it starts, but works just fine otherwise.
I'll see what I can do though.

> Please include your platform details and the tcl version.

# uname -a
Linux ... 2.6.17-1.2157_FC5 #1 SMP Tue Jul 11 22:53:56 EDT 2006 x86_64
x86_64 x86_64 GNU/Linux
# rpm -q tcl
tcl-8.4.13-1.1

> Also if this
> is intermittent or not and if you use telnet $smtphost 25 do you
> connect ok.

No problem at all with telnet even while the other application is
failing, so I don't think the problem lies with sendmail.

> FWIW I know some windows virus checkers redirect outgoing port 25 to
> a local forwarder so that they can scan sent mail. You might also want
> to see if you can use the submission port (587) to send mail instead
> of 25.

No, Linux and port 25. I don't think I can use 587 on this server
without disturbing the email service (sendmail)...

Pat Thoyts

unread,
Oct 19, 2006, 8:36:26 AM10/19/06
to
jfon...@free.fr writes:

>> My understanding of this would be that a DNS error occurred as all the
>> connection stuff should be happening asynchronously.
>I doubt it since the server is "localhost".

Yeah - I re-read your first post after I posted the last message. I've
also tried flogging a local system here to no avail. Its a strange
error and I can't think why you would get to that location except for
name resolution problems. The other other thing that occurs to me is
that perhaps there is a concurrency problem that leads to one tcl
session getting an invalid sockaddr structure from the resolver
library. I can only think that this is a Tcl sockets issue given that
you have not event got connected by the time you get an error so the
smtp package isn't doing anything wrong.

># uname -a
>Linux ... 2.6.17-1.2157_FC5 #1 SMP Tue Jul 11 22:53:56 EDT 2006 x86_64
>x86_64 x86_64 GNU/Linux
># rpm -q tcl
>tcl-8.4.13-1.1

>No, Linux and port 25. I don't think I can use 587 on this server


>without disturbing the email service (sendmail)...

sendmail usually listens on both 25 and 587 in modern systems. OTOH I
suspect this won't help. Be interesting to see if Jeff Hobbs has ever
come across something similar as he gets to use some fairly large
systems from time to time.

jfon...@free.fr

unread,
Oct 19, 2006, 8:48:10 AM10/19/06
to
On Oct 19, 2:36 pm, Pat Thoyts <cnggub...@hfref.fbheprsbetr.arg> wrote:

> jfont...@free.fr writes:
> >> My understanding of this would be that a DNS error occurred as all the
> >> connection stuff should be happening asynchronously.
> >I doubt it since the server is "localhost".
> Yeah - I re-read your first post after I posted the last message. I've
> also tried flogging a local system here to no avail. Its a strange
> error and I can't think why you would get to that location except for
> name resolution problems. The other other thing that occurs to me is
> that perhaps there is a concurrency problem that leads to one tcl
> session getting an invalid sockaddr structure from the resolver
> library. I can only think that this is a Tcl sockets issue given that
> you have not event got connected by the time you get an error so the
> smtp package isn't doing anything wrong.

It could be, since that is happening inside slave interpreters (200 or
so loaded).

> ># uname -a
> >Linux ... 2.6.17-1.2157_FC5 #1 SMP Tue Jul 11 22:53:56 EDT 2006 x86_64
> >x86_64 x86_64 GNU/Linux
> ># rpm -q tcl
> >tcl-8.4.13-1.1
> >No, Linux and port 25. I don't think I can use 587 on this server

> >without disturbing the email service (sendmail)...sendmail usually listens on both 25 and 587 in modern systems. OTOH I


> suspect this won't help. Be interesting to see if Jeff Hobbs has ever
> come across something similar as he gets to use some fairly large
> systems from time to time.

Jeff, are you listening?
I am willing to start debugging at the C level...

Thanks very much for your help!

JL

jfon...@free.fr

unread,
Nov 9, 2006, 4:25:25 AM11/9/06
to
jfon...@free.fr wrote:
> Pat Thoyts wrote:
>
> > Add -debug 1 to the list of options given to smtp::sendmessage. This
> > will dump out the SMTP transactions to stdout.

I investigated a bit more:

proc echo {args} {foreach argument $args {puts -nonewline "$argument
"}; puts {}}
proc ::smtp::readable {token} {
# FRINK: nocheck
variable $token
upvar 0 $token state

if {[catch { array set options $state(options) }]} {
return
}
set state(line) ""
if {[catch { gets $state(sd) state(line) } result]} {
set state(readable) -2
echo set state(error) $result
set state(error) $result
} elseif {$result == -1} {
echo result == -1
if {[eof $state(sd)]} {
set state(readable) -3
echo set state(error) "premature end-of-file from server"
set state(error) "premature end-of-file from server"
}
} else {
echo $state(line)
# If the line ends in \r, remove the \r.
if {![string compare [string index $state(line) end] "\r"]} {
set state(line) [string range $state(line) 0 end-1]
}
set state(readable) 1
}
if {$state(readable) < 0} {
echo $state(readable) < 0
if {$options(-debug)} {
puts stderr " ... $state(error) ..."
flush stderr
}
catch { fileevent $state(sd) readable "" }
}
}

which gives:
Trying 127.0.0.1...
result == -1
result == -1
result == -1
result == -1
... (loops / 100% CPU)

What can I do to debug further?

Thanks for your help!

Jean-Luc

0 new messages