简体   繁体   English

在 pop3 连接上间歇性出现 javax.mail.AuthenticationFailedException 的协议错误

[英]Protocol error with javax.mail.AuthenticationFailedException appearing intermittently on pop3 connect

I have a javamail program to read emails to my pop3 account at regular intervals.我有一个 javamail 程序来定期阅读我的 pop3 帐户的电子邮件。 It connects and works successfully most of the times.它在大多数情况下都能连接并成功运行。 But, after a while I start getting javax.mail.AuthenticationFailedException and unable to connect it on further calls.但是,过了一会儿,我开始收到javax.mail.AuthenticationFailedException并且无法在进一步的调用中连接它。 And when i shut and start my program it start connecting successfully again with same credentials.当我关闭并启动我的程序时,它会使用相同的凭据再次成功连接。 For further analysis, I enabled session debug logs.为了进一步分析,我启用了 session 调试日志。 Following is the command trace output:以下是命令跟踪 output:

@2021-05-17 12:36:08.150 !DEBUG      +OK The Microsoft Exchange POP3 service is ready. #27820545
@2021-05-17 12:36:08.150 !DEBUG      CAPA     #27820545
@2021-05-17 12:36:08.150 !DEBUG      +OK       #27820545
@2021-05-17 12:36:08.150 !DEBUG      TOP        #27820545
@2021-05-17 12:36:08.150 !DEBUG      UIDL      #27820545
@2021-05-17 12:36:08.150 !DEBUG      SASL PLAIN         #27820545
@2021-05-17 12:36:08.150 !DEBUG      USER     #27820545
@2021-05-17 12:36:08.150 !DEBUG      STLS       #27820545
@2021-05-17 12:36:08.150 !DEBUG      .               #27820545
@2021-05-17 12:36:08.150 !DEBUG      DEBUG POP3: authentication command trace suppressed          #27820545
@2021-05-17 12:36:50.341 !DEBUG      DEBUG POP3: authentication command failed #27862736
@2021-05-17 12:36:50.342 !DEBUG      QUIT      #27862737
@2021-05-17 12:36:50.342 !DEBUG      -ERR Protocol error. 19   #27862737
@2021-05-17 12:37:50.371 !DEBUG      DEBUG: getProvider() returning javax.mail.Provider[STORE,pop3,com.sun.mail.pop3.POP3Store,Oracle]          #27922766
@2021-05-17 12:37:50.371 !DEBUG     DEBUG POP3: mail.pop3.rsetbeforequit: false #27922766
@2021-05-17 12:37:50.371 !DEBUG     DEBUG POP3: mail.pop3.disabletop: false          #27922766 

What could be cause for this?这可能是什么原因? The account service provider is Microsoft Exchange.帐户服务提供商是 Microsoft Exchange。 What does protocol error.19 indicate?协议错误.19 表示什么?

I suspect that the authentication credentials supplied for the POP server have expired or you are using the same Session for all of your connections and it expires after a while.我怀疑为 POP 服务器提供的身份验证凭据已过期,或者您对所有连接都使用相同的 Session 并且它会在一段时间后过期。 But like @JRichardsz says, please attach an snippet of your code and the exception stack.但就像@JRichardsz 所说,请附上您的代码片段和异常堆栈。

That it works for some time before it stops working out of a sudden, and that it works again after you just restarted your program allows the assumption that nothing is wrong with your code as such.它可以工作一段时间,然后突然停止工作,并且在您刚刚重新启动程序后再次工作,可以假设您的代码没有任何问题。

Do you connect to a local Exchange server, or to Office365?您是连接到本地 Exchange 服务器,还是连接到 Office365?

The latter imposes several limit values for various service activities, and in case of email you get an authentication failure when one of this limits is hit.后者对各种服务活动施加了几个限制值,在 email 的情况下,当达到其中一个限制时,您会遇到身份验证失败。

You can configure the same or similar limits on your local Exchange, too, and will get the same error behaviour when you hit them.您也可以在本地 Exchange 上配置相同或类似的限制,当您点击它们时会得到相同的错误行为。

In your case I assume that you hit a limit for the number of login attempts within a given period of time.在您的情况下,我假设您在给定时间段内达到了登录尝试次数的限制。 Check what happens if you ping your mail box less frequently.检查如果您不那么频繁地 ping 邮箱会发生什么。

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

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