eclipse-ee4j / eclipse-ee4j/angus-mail
Random AuthenticationFailedException when connecting via pop3s to outlook.office365.com
- Dominant language
- Java
- Stars
- 87
- Forks
- 23
- PR merge metrics
- No merged PRs in 30d
Description
For the past couple of weeks, it has been happening very frequently that the call to the method jakarta.mail.Store.connect("outlook.office365.com", 995, mailUser, token);
triggers the mail.pop3s.writetimeout (set to 30 seconds) with the following exception:
::: AuthenticationFailedException stackTrace ::: jakarta.mail.AuthenticationFailedException: Cannot read field "ok" because "this.resp" is null
at org.eclipse.angus.mail.pop3.POP3Store.protocolConnect(POP3Store.java:194)
at jakarta.mail.Service.connect(Service.java:345)
...
Enabling debug mode, I get this error:
DEBUG: getProvider() returning jakarta.mail.Provider[STORE,pop3s,org.eclipse.angus.mail.pop3.POP3SSLStore,Oracle]
DEBUG POP3: mail.pop3s.rsetbeforequit: false
DEBUG POP3: mail.pop3s.disabletop: false
DEBUG POP3: mail.pop3s.forgettopheaders: false
DEBUG POP3: mail.pop3s.cachewriteto: false
DEBUG POP3: mail.pop3s.filecache.enable: false
DEBUG POP3: mail.pop3s.keepmessagecontent: false
DEBUG POP3: mail.pop3s.starttls.enable: true
DEBUG POP3: mail.pop3s.starttls.required: false
DEBUG POP3: mail.pop3s.finalizecleanclose: false
DEBUG POP3: mail.pop3s.apop.enable: false
DEBUG POP3: mail.pop3s.disablecapa: false
DEBUG POP3: connecting to host "outlook.office365.com", port 995, isSSL true
+OK The Microsoft Exchange POP3 service is ready.
CAPA
+OK
TOP
UIDL
SASL PLAIN XOAUTH2
USER
.
DEBUG POP3: Attempt to authenticate using mechanisms: XOAUTH2
DEBUG POP3: Using mechanism XOAUTH2
DEBUG POP3: AUTH XOAUTH2 command trace suppressed
DEBUG POP3: mail.pop3s.auth.xoauth2.two.line.authentication.format: true
DEBUG POP3: AUTH XOAUTH2 using two line authentication format
DEBUG POP3: AUTH XOAUTH2 failed, THROW:
java.io.EOFException: Read timed out
at org.eclipse.angus.mail.pop3.Protocol.readResponse(Protocol.java:1223)
at org.eclipse.angus.mail.pop3.Protocol.simpleCommand(Protocol.java:1164)
at org.eclipse.angus.mail.pop3.Protocol.twoLinesCommand(Protocol.java:1184)
at org.eclipse.angus.mail.pop3.Protocol.access$900(Protocol.java:72)
at org.eclipse.angus.mail.pop3.Protocol$OAuth2Authenticator.runAuthenticationCommand(Protocol.java:723)
at org.eclipse.angus.mail.pop3.Protocol$Authenticator.authenticate(Protocol.java:496)
at org.eclipse.angus.mail.pop3.Protocol.authenticate(Protocol.java:321)
at org.eclipse.angus.mail.pop3.POP3Store.authenticate(POP3Store.java:433)
at org.eclipse.angus.mail.pop3.POP3Store.getPort(POP3Store.java:287)
at org.eclipse.angus.mail.pop3.POP3Store.protocolConnect(POP3Store.java:192)
at jakarta.mail.Service.connect(Service.java:345)
.....
I'm using the latest versions of Jakarta Mail and Angus.
I have Java processes that call the connect method every 30 seconds. Lately, the above error occurs about once an hour across different Exchange tenants.
In previous years, when issues like this arose, I always resolved them by updating the JavaMail jars. This is the first time it’s happening with Jakarta Mail and Angus. Is a new version expected to be released to fix this issue?
Contributor guide
Research direction
Start by reading org.eclipse.angus.mail.pop3.POP3Store.java around protocolConnect and Protocol.java around readResponse and twoLinesCommand. Use the supplied POP3S XOAUTH2 debug trace and timeout details to investigate the intermittent response failure. Done means the cause is identified and POP3S authentication no longer produces this failure, with verification for the reported connection scenario.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- authentication, networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 32/100