2 Replies Latest reply: Sep 6, 2012 11:30 AM by 859967 RSS

    smtp transport disconnected with multi thread


      I knew that we can share session in SMTP. But when i run in multi threading, i used to face transport disconnection problem. I don't know if sharing a session is a good idea? Or if you know how to avoid transport disconnected issue.


      p/s: i don't use session synchronization as mentioned in some discussing threads in this forum.

      Edited by: CardM on Sep 4, 2012 8:10 AM
        • 1. Re: smtp transport disconnected with multi thread
          Bill Shannon-Oracle
          I'm not completely clear on what it is you're doing...

          You can definitely share a JavaMail Session object between threads since the Session contains
          only configuration information.

          Sharing a JavaMail Transport object between threads is not a good idea. A Transport represents
          a connection to the mail server and only one thread can use the connection at a time.

          If you open a Transport connection and keep it around for a long time without using it, the server
          may close the connection. Servers want you to open connections only when you're using them.
          Servers also don't want you to abuse a connection and so may close a connection if they think
          you're using it too much (e.g., to send spam). You can't prevent either of these actions, but you
          can detect that the connection has been closed and open a new connection when you need it.
          • 2. Re: smtp transport disconnected with multi thread
            thanks, i also agreed with the only solution which is to reopen the connection if it is closed before sending mail out.