I’m Running Tomcat7 on a server (right now it’s a virtual machine but should be configured as unlimited connexions).
I have connexions with a SMTP server and also with facebook Servers.
My traffic is around 250hits/mins.
I’m running djabberd with around a few hundreds connected users average time.
Sometimes I get :
javax.mail.MessagingException: Could not connect to SMTP host: xxx.xxx.xxx.xxx, port: xxxxx;
nested exception is:
java.net.SocketException: No buffer space available
at com.sun.mail.smtp.SMTPTransport.openServer(SMTPTransport.java:1934)
at com.sun.mail.smtp.SMTPTransport.protocolConnect(SMTPTransport.java:638)
at javax.mail.Service.connect(Service.java:295)
at javax.mail.Service.connect(Service.java:176)
at javax.mail.Service.connect(Service.java:125)
at javax.mail.Transport.send0(Transport.java:194)
at javax.mail.Transport.send(Transport.java:124)
at xxxxxxxxxxxxxxxx.controllers.EmailManager.sendEmail(EmailManager.java:151)
Or same error connecting to facebook servers.
netstat -n | wc -l
348
Tomcat can accept acceptCount=”1024″ connexions.
Where should I investigate ?
[UPDATE 1]
Send an email :
Context envContext = (Context) initContext.lookup("java:/comp/env");
session = (javax.mail.Session) envContext.lookup("mail/emailSession");
MimeMessage message = new MimeMessage(session);
//....
Transport.send(message);
Configuration :
<resource-ref>
<description>
JNDI javamail session resource reference
</description>
<res-ref-name>mail/emailSession</res-ref-name>
<res-type>javax.mail.Session</res-type>
<res-auth>Container</res-auth>
</resource-ref>
Facebook connexion :
FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
User user = facebookClient.fetchObject("me", User.class);
What OS? Linux? You are probably hitting the limit on the max number of client sockets, there is no such thing as unlimited connections. Either somewhere in your app you aren’t closing the connections or you just have too many open. “Too many” may be a lot lower than you think because it is limited by the max number of file descriptors a process can have open. If you are running Linux, take a look at http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/