You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Raymond Holguin <ra...@ucr.edu> on 2007/05/04 21:37:45 UTC
Tomcat randomly cannot connect to SMTP host
Hello,
I have tomcat 5.0.28 running on my Linux machine, and all my
applications running under this tomcat experience the same problem at
the same time which is why I believe it to be a tomcat issue.
When my applications attempt to send out an email I get this error message
(Mail server connection failed; nested exception is
javax.mail.MessagingException: Could not connect to SMTP host: xxxxxx,
port: 25; nested exception is: java.net.ConnectException: Connection
refused)
The SMTP server is fine, because I can use it from other applications
not on that tomcat server. I can also telnet into the SMTP server just
fine from that same machine, so i don't believe its a server/port
blocking issue on the OS or hardware level. The only way I am able to
resolve the problem is to restart Tomcat. Once Tomcat is restarted,
then all operation with emailing works fine again. I cannot seem to
force the issue to happen so i don't know how reproduce it on demand,
even though I know that would help in solving the issue. This problem
just seems to come up randomly and wont go away until I restart tomcat.
If anyone can please help me solve this issue that would be greatly
appreciated. I have important applications running on this machine and
its a great inconvenience to those using the applications when this
problem comes up.
Thank you
-Ray
--
------------------------------------------------------------------------
Raymond Holguin
Programmer Analyst
College of Humanities, Arts, and Social Sciences
Tel: (951) 827-6212
Email: rholguin@ucr.edu
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat randomly cannot connect to SMTP host
Posted by Pid <p...@pidster.com>.
Caldarale, Charles R wrote:
>> From: Raymond Holguin [mailto:raymond.holguin@ucr.edu]
>> Subject: Re: Tomcat randomly cannot connect to SMTP host
>>
>> As for wireshark, this is a production environment and im
>> not really supposed to be installing programs on the server.
>
> Try running it from your Tomcat box then. You won't get any information
> about the DNS requests the SMTP server is making (if any), but at least
> you'll see the actual messages between your webapp and the SMTP server.
one reason the issue might not go away once it develops is if you are
caching (by means of a static variable, perhaps) a broken object.
does your code create everything fresh each time?
what does your code actually do; e.g. are you trying to open too many
connections to the mail server?
p
>> Are there any built-in utilities that might give the same effect?
>
> Quite likely, but you'll probably still need admin or root privileges on
> the server to run it. Talk to your friendly neighborhood sysadmin for
> help getting traces from the SMTP server.
>
> - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
RE: Tomcat randomly cannot connect to SMTP host
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Raymond Holguin [mailto:raymond.holguin@ucr.edu]
> Subject: Re: Tomcat randomly cannot connect to SMTP host
>
> As for wireshark, this is a production environment and im
> not really supposed to be installing programs on the server.
Try running it from your Tomcat box then. You won't get any information
about the DNS requests the SMTP server is making (if any), but at least
you'll see the actual messages between your webapp and the SMTP server.
> Are there any built-in utilities that might give the same effect?
Quite likely, but you'll probably still need admin or root privileges on
the server to run it. Talk to your friendly neighborhood sysadmin for
help getting traces from the SMTP server.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat randomly cannot connect to SMTP host
Posted by Raymond Holguin <ra...@ucr.edu>.
Thanks for the reply guys,
But i don't think i quite understand what your getting at with the
DNS stuff. The server is on my school's campus, and im using the campus
SMTP server. Im able to send email using the same SMTP just fine from
non-tomcat applications on the same server. I also don't think it has
anything to do with the actual SMTP server since the problem goes away
if I restart tomcat.
As for wireshark, this is a production environment and im not really
supposed to be installing programs on the server. Are there any
built-in utilities that might give the same effect? maybe like
tcpdump? if so what cmdline args would I run to get the desired
information?
Thanks
-Ray
Caldarale, Charles R wrote:
>> From: Johnny Kewl [mailto:john@kewlstuff.co.za]
>> Subject: Re: Tomcat randomly cannot connect to SMTP host
>>
>> Heres my theory.... check the DNS on "your" mail address.... I have a
>> feeling that if the mail server cannot resolve your mail
>> address "domain"...
>> it will refuse the connection on a send.
>>
>> ... so if the DNS server is giving problems... your email goes to the
>> dogs... maybe.
>>
>
> A Wireshark trace taken from the SMTP server point of view should be
> quite illuminating.
>
> - Chuck
>
>
> THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
> MATERIAL and is thus for use only by the intended recipient. If you
> received this in error, please contact the sender and delete the e-mail
> and its attachments from all computers.
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
>
--
------------------------------------------------------------------------
Raymond Holguin
Programmer Analyst
College of Humanities, Arts, and Social Sciences
Tel: (951) 827-6212
Email: rholguin@ucr.edu
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Tomcat randomly cannot connect to SMTP host
Posted by "Caldarale, Charles R" <Ch...@unisys.com>.
> From: Johnny Kewl [mailto:john@kewlstuff.co.za]
> Subject: Re: Tomcat randomly cannot connect to SMTP host
>
> Heres my theory.... check the DNS on "your" mail address.... I have a
> feeling that if the mail server cannot resolve your mail
> address "domain"...
> it will refuse the connection on a send.
>
> ... so if the DNS server is giving problems... your email goes to the
> dogs... maybe.
A Wireshark trace taken from the SMTP server point of view should be
quite illuminating.
- Chuck
THIS COMMUNICATION MAY CONTAIN CONFIDENTIAL AND/OR OTHERWISE PROPRIETARY
MATERIAL and is thus for use only by the intended recipient. If you
received this in error, please contact the sender and delete the e-mail
and its attachments from all computers.
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat randomly cannot connect to SMTP host
Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
Hi Raymond... going to have a wild guess...
I dont think its tomcat... but for some reason the mail server is telling
tomcat to get lost.
Is it a microsoft mail server?..... ha ha... no just kidding.
Heres my theory.... check the DNS on "your" mail address.... I have a
feeling that if the mail server cannot resolve your mail address "domain"...
it will refuse the connection on a send.
... so if the DNS server is giving problems... your email goes to the
dogs... maybe.
----- Original Message -----
From: "Raymond Holguin" <ra...@ucr.edu>
To: <us...@tomcat.apache.org>
Sent: Friday, May 04, 2007 9:37 PM
Subject: Tomcat randomly cannot connect to SMTP host
> Hello,
> I have tomcat 5.0.28 running on my Linux machine, and all my
> applications running under this tomcat experience the same problem at the
> same time which is why I believe it to be a tomcat issue.
> When my applications attempt to send out an email I get this error message
>
> (Mail server connection failed; nested exception is
> javax.mail.MessagingException: Could not connect to SMTP host: xxxxxx,
> port: 25; nested exception is: java.net.ConnectException: Connection
> refused)
>
> The SMTP server is fine, because I can use it from other applications not
> on that tomcat server. I can also telnet into the SMTP server just fine
> from that same machine, so i don't believe its a server/port blocking
> issue on the OS or hardware level. The only way I am able to resolve the
> problem is to restart Tomcat. Once Tomcat is restarted, then all
> operation with emailing works fine again. I cannot seem to force the
> issue to happen so i don't know how reproduce it on demand, even though I
> know that would help in solving the issue. This problem just seems to
> come up randomly and wont go away until I restart tomcat.
> If anyone can please help me solve this issue that would be greatly
> appreciated. I have important applications running on this machine and
> its a great inconvenience to those using the applications when this
> problem comes up.
> Thank you
> -Ray
>
> --
> ------------------------------------------------------------------------
> Raymond Holguin
> Programmer Analyst
> College of Humanities, Arts, and Social Sciences
> Tel: (951) 827-6212
> Email: rholguin@ucr.edu
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat randomly cannot connect to SMTP host
Posted by Johnny Kewl <jo...@kewlstuff.co.za>.
Sorry missed your reply...
Thanks for showing us the code and Aaaarg! you using a framework... but, its
ok, the tomcat guys are just much nicer than those in Springs mailing list,
hey!... ha ha.
I avoid frameworks, but I had a quick look... seems like they store the
session object in an EJB container and let you inject it into any servlet...
or maybe its just a common class loader instance... doesnt really matter.
Just wanted to say that "your" code seems to be thread safe, but I seem to
remember and I cant remember where I read it, that if you set the FROM
attribute in different threads... which will happen on multiple requests...
then each one should have its own session object.
So... I think you have two choices if it happens again....
1) Set up your own session object... this will let you control the
properties and you can stay away from default system properties which I
think is inherently buggy... and then inject that into the the framework....
I'm not sure but I have a feeling that mailSender class will allow you to
set a session... just figure out how, on that framework... then I think the
locking behaviour will not reoccur.
2) This is more of a question... but when I looked at the framework code, it
seems to be synchronous... ie the user will wait in the browser until the
mail is sent and the request returns...
So I imagine your problems start with a user moaning at u.
Another way is to take that code and stick it in a background thread... ie
its just one mail session running and pumping out emails... and the user
mail is simply Q'd. If there is an error the mail that must still go is
written to a "still to go log".... that way users get an immediate return...
etc.
I use this methodology.... if the mail server is down... it will go as soon
as it comes back... and users never bitch at you ;)
Last thing is that if you do get the hell-in with the framework... using
JavaMail directly, really isnt that much code...
Good luck...
----- Original Message -----
From: "Raymond Holguin" <ra...@ucr.edu>
To: "Tomcat Users List" <us...@tomcat.apache.org>
Sent: Monday, May 07, 2007 10:51 PM
Subject: Re: Tomcat randomly cannot connect to SMTP host
> Dear all,
> Yes you have all given me great advice and I appreciate it. Like I
> mentioned this is a random issue that occurs, and currently it is working
> fine. So when it goes down again I will try out some of your suggestions.
> As for the code its a basic spring bean setup for the mailer
>
> <bean id="mailSender"
> class="org.springframework.mail.javamail.JavaMailSenderImpl">
> <property name="host"><value>smtp.xxx.xxx</value></property>
> </bean>
>
> Then in my java code I have a service class that I call whenever I want to
> send a message
>
> private void sendMsg(String subject, String msgString, String[] toMail,
> String fromMail, String[] ccMail) throws FRSException {
> try {
> SimpleMailMessage msg = new SimpleMailMessage();
> msg.setTo(toMail) {
> if ( ccMail != null) {
> msg.setCc(ccMail);
> }
> msg.setSubject(subject);
> msg.setFrom(fromMail);
> msg.setSentDate(Calendar.getInstance().getTime());
> msg.setText(new String(msgString));
> mailSender.send(msg);
> } catch (MailException me) {
> logger.error(me);
> throw new FRSException(me.getMessage());
> }
> }
>
> Fargusson.Alan wrote:
>> I see you got a number of good suggestions. If you still have this
>> problem you could try doing a netstat command to see if your server is
>> holding the connections to the SMTP server. I have seen this type of
>> thing cause some weird problems.
>>
>> If your server is holding several connections to the SMTP server it would
>> mean that the application isn't closing the socket when it is done.
>>
>> -----Original Message-----
>> From: Raymond Holguin [mailto:raymond.holguin@ucr.edu]
>> Sent: Friday, May 04, 2007 12:38 PM
>> To: users@tomcat.apache.org
>> Subject: Tomcat randomly cannot connect to SMTP host
>>
>>
>> Hello,
>> I have tomcat 5.0.28 running on my Linux machine, and all my
>> applications running under this tomcat experience the same problem at the
>> same time which is why I believe it to be a tomcat issue.
>> When my applications attempt to send out an email I get this error
>> message
>>
>> (Mail server connection failed; nested exception is
>> javax.mail.MessagingException: Could not connect to SMTP host: xxxxxx,
>> port: 25; nested exception is: java.net.ConnectException: Connection
>> refused)
>>
>> The SMTP server is fine, because I can use it from other applications not
>> on that tomcat server. I can also telnet into the SMTP server just fine
>> from that same machine, so i don't believe its a server/port blocking
>> issue on the OS or hardware level. The only way I am able to resolve the
>> problem is to restart Tomcat. Once Tomcat is restarted, then all
>> operation with emailing works fine again. I cannot seem to force the
>> issue to happen so i don't know how reproduce it on demand, even though I
>> know that would help in solving the issue. This problem just seems to
>> come up randomly and wont go away until I restart tomcat.
>> If anyone can please help me solve this issue that would be greatly
>> appreciated. I have important applications running on this machine and
>> its a great inconvenience to those using the applications when this
>> problem comes up.
>> Thank you
>> -Ray
>>
>>
>
>
> --
> ------------------------------------------------------------------------
> Raymond Holguin
> Programmer Analyst
> College of Humanities, Arts, and Social Sciences
> Tel: (951) 827-6212
> Email: rholguin@ucr.edu
>
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@tomcat.apache.org
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
Re: Tomcat randomly cannot connect to SMTP host
Posted by Raymond Holguin <ra...@ucr.edu>.
Dear all,
Yes you have all given me great advice and I appreciate it. Like I
mentioned this is a random issue that occurs, and currently it is
working fine. So when it goes down again I will try out some of your
suggestions. As for the code its a basic spring bean setup for the mailer
<bean id="mailSender"
class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host"><value>smtp.xxx.xxx</value></property>
</bean>
Then in my java code I have a service class that I call whenever I want
to send a message
private void sendMsg(String subject, String msgString, String[] toMail,
String fromMail, String[] ccMail) throws FRSException {
try {
SimpleMailMessage msg = new SimpleMailMessage();
msg.setTo(toMail) {
if ( ccMail != null) {
msg.setCc(ccMail);
}
msg.setSubject(subject);
msg.setFrom(fromMail);
msg.setSentDate(Calendar.getInstance().getTime());
msg.setText(new String(msgString));
mailSender.send(msg);
} catch (MailException me) {
logger.error(me);
throw new FRSException(me.getMessage());
}
}
Fargusson.Alan wrote:
> I see you got a number of good suggestions. If you still have this problem you could try doing a netstat command to see if your server is holding the connections to the SMTP server. I have seen this type of thing cause some weird problems.
>
> If your server is holding several connections to the SMTP server it would mean that the application isn't closing the socket when it is done.
>
> -----Original Message-----
> From: Raymond Holguin [mailto:raymond.holguin@ucr.edu]
> Sent: Friday, May 04, 2007 12:38 PM
> To: users@tomcat.apache.org
> Subject: Tomcat randomly cannot connect to SMTP host
>
>
> Hello,
> I have tomcat 5.0.28 running on my Linux machine, and all my
> applications running under this tomcat experience the same problem at
> the same time which is why I believe it to be a tomcat issue.
> When my applications attempt to send out an email I get this error message
>
> (Mail server connection failed; nested exception is
> javax.mail.MessagingException: Could not connect to SMTP host: xxxxxx,
> port: 25; nested exception is: java.net.ConnectException: Connection
> refused)
>
> The SMTP server is fine, because I can use it from other applications
> not on that tomcat server. I can also telnet into the SMTP server just
> fine from that same machine, so i don't believe its a server/port
> blocking issue on the OS or hardware level. The only way I am able to
> resolve the problem is to restart Tomcat. Once Tomcat is restarted,
> then all operation with emailing works fine again. I cannot seem to
> force the issue to happen so i don't know how reproduce it on demand,
> even though I know that would help in solving the issue. This problem
> just seems to come up randomly and wont go away until I restart tomcat.
> If anyone can please help me solve this issue that would be greatly
> appreciated. I have important applications running on this machine and
> its a great inconvenience to those using the applications when this
> problem comes up.
> Thank you
> -Ray
>
>
--
------------------------------------------------------------------------
Raymond Holguin
Programmer Analyst
College of Humanities, Arts, and Social Sciences
Tel: (951) 827-6212
Email: rholguin@ucr.edu
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
RE: Tomcat randomly cannot connect to SMTP host
Posted by "Fargusson.Alan" <Al...@ftb.ca.gov>.
I see you got a number of good suggestions. If you still have this problem you could try doing a netstat command to see if your server is holding the connections to the SMTP server. I have seen this type of thing cause some weird problems.
If your server is holding several connections to the SMTP server it would mean that the application isn't closing the socket when it is done.
-----Original Message-----
From: Raymond Holguin [mailto:raymond.holguin@ucr.edu]
Sent: Friday, May 04, 2007 12:38 PM
To: users@tomcat.apache.org
Subject: Tomcat randomly cannot connect to SMTP host
Hello,
I have tomcat 5.0.28 running on my Linux machine, and all my
applications running under this tomcat experience the same problem at
the same time which is why I believe it to be a tomcat issue.
When my applications attempt to send out an email I get this error message
(Mail server connection failed; nested exception is
javax.mail.MessagingException: Could not connect to SMTP host: xxxxxx,
port: 25; nested exception is: java.net.ConnectException: Connection
refused)
The SMTP server is fine, because I can use it from other applications
not on that tomcat server. I can also telnet into the SMTP server just
fine from that same machine, so i don't believe its a server/port
blocking issue on the OS or hardware level. The only way I am able to
resolve the problem is to restart Tomcat. Once Tomcat is restarted,
then all operation with emailing works fine again. I cannot seem to
force the issue to happen so i don't know how reproduce it on demand,
even though I know that would help in solving the issue. This problem
just seems to come up randomly and wont go away until I restart tomcat.
If anyone can please help me solve this issue that would be greatly
appreciated. I have important applications running on this machine and
its a great inconvenience to those using the applications when this
problem comes up.
Thank you
-Ray
--
------------------------------------------------------------------------
Raymond Holguin
Programmer Analyst
College of Humanities, Arts, and Social Sciences
Tel: (951) 827-6212
Email: rholguin@ucr.edu
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org
---------------------------------------------------------------------
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org