Open qjebbs opened 3 days ago
Realized that it not the client library's responsibility for this issue, and there exits a workaround for this library. Closing...
It turns out imaphz.qiye.163.com
is the one that complies with the RFC 3501 specification
Therefore,
if the client sends any command other than FETCH, STORE, or SEARCH, it
MUST wait for the completion result response before sending a command
with message sequence numbers.
We need a global lock to wait for the async, background-spawned CAPABILITY
done.
This paragraph only applies to the "selected" state. If the connection isn't in the "selected" state, an untagged EXPUNGE response cannot be sent by the server.
This paragraph only applies to the "selected" state. If the connection isn't in the "selected" state, an untagged EXPUNGE response cannot be sent by the server.
Sorry, I didn't read it carefully.
What's your suggestion for the situation when we work with the server like this topic? If global lock is not an option, I would say, make the background spawned CAPABILITY command synchronized and blocked?
Does it help to call c.Caps()
before c.Login()
?
Does it help to call
c.Caps()
beforec.Login()
?
I am afraid it doesn't.
c.Caps()
is similar to what I so called workaround, by spawning another capability command and waiting. It solves half of the problem, making sure login command not being ignored.
But if it happens this capability command is ignored, the login will be delayed for 60 seconds respReadTimeout
. Making background capability command synchronized and blocking will solve all the problem.
Backgroud:
imaphz.qiye.163.com
here) seems to ignore new commands when the current command is still being processed.UPDATE:
imaphz.qiye.163.com
is not the one to blame, the RFC 3501 specification says:Consider the following code:
The
LOGIN
and background spawnedCAPABILITY
are executed in different goroutines. The order of the commands is not guaranteed. So I see a random failure when initializing the imapclient.If the
CAPABILITY
command is executed first, and theLOGIN
command is executed before theCAPABILITY
command finishes, the server seems to ignore theLOGIN
command. The command receives nothing and reports an unexpected EOF error after 60 seconds.If the
LOGIN
command happens to be executed first, the server will respond. (CAPABILITY
command is ignored until timeout. Though the client initialized with success)Though It's the server's fault, I can't change the server's behavior. Is there a way to fix this issue? Maybe to lock up imapclient before a background command finishes (not accept new ones)?Workaround
UPDATE: In theory, there is no workaround to this problem