简体   繁体   English

从Tomcat发送SMTP消息时出错:没有可用的缓冲区空间

[英]Error sending SMTP message from Tomcat: No buffer space available

I'm Running Tomcat7 on a server (right now it's a virtual machine but should be configured as unlimited connexions). 我在服务器上运行Tomcat7 (现在它是一个虚拟机,但应配置为无限连接)。

I have connexions with a SMTP server and also with facebook Servers. 我与SMTP服务器以及Facebook服务器有联系。 My traffic is around 250hits/mins. 我的车流量约为250马力/分钟。

I'm running djabberd with around a few hundreds connected users average time. 我正在运行djabberd,平均时间约为几百个连接用户。

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. 或连接到Facebook服务器的相同错误。

netstat -n | wc -l 
348

Tomcat can accept acceptCount="1024" connexions. Tomcat可以接受acceptCount =“1024”连接。

Where should I investigate ? 我应该去哪里调查?

[UPDATE 1] [更新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 : Facebook连接:

FacebookClient facebookClient = new DefaultFacebookClient(accessToken);
User user = facebookClient.fetchObject("me", User.class);

What OS? 什么OS? Linux? 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/ 如果您正在运行Linux,请查看http://www.cyberciti.biz/faq/linux-increase-the-maximum-number-of-open-files/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM