Why JavaMail connection timeout is too long

后端 未结 5 940
广开言路
广开言路 2021-02-04 02:04

In my application I connect to server to authenticate users. This is code:

try {
        Properties prop = new Properties();
        prop.put(\"mail.smtp.startt         


        
相关标签:
5条回答
  • 2021-02-04 02:22

    Since you're using SSL, you can try to configure smtps namespace, not smtp:

    prop.put("mail.smtps.timeout", 1000);
    prop.put("mail.smtps.connectiontimeout", 1000);
    

    BTW: Timeout values in the properties can be passed as int, as well as String. JavaMail will handle them both properly (at least v1.5+).

    0 讨论(0)
  • 2021-02-04 02:27

    I resolve my problem by changing to the newest version of JavaMail (to JavaMail 1.5). I write about it there: http://openejb.979440.n4.nabble.com/Which-version-of-JavaMail-td4665285.html

    thank's everybody for help, specially to Bill Shannon :)

    0 讨论(0)
  • 2021-02-04 02:33

    I had the same problem. It worked with the String instead of integer.

    prop.put("mail.smtp.timeout", "1000");    
    prop.put("mail.smtp.connectiontimeout", "1000");    
    
    0 讨论(0)
  • 2021-02-04 02:36

    Can you setup the Socket I/O timeout as well. When it is connected but failed to read data from the server then it will continue to wait.

    prop.put("mail.smtp.timeout", 1000);
    

    Read timeout indicates you are connected but not able to read data from the server.

    0 讨论(0)
  • 2021-02-04 02:39

    No, it is just because value must be a string "1000" and not an integer 1000

    0 讨论(0)
提交回复
热议问题