Thunderbird Copy to Sent IMAP Connection Error
Posted by Christopher Wojno Fri, 21 Dec 2007 05:46:00 GMT
This article applies to: Thunderbird v.2.0.0.9 and a few previous versions and may very well be applicable in the future.
The Solution
I’m assuming you want the solution and not the explanation. If you really do want the explanation, scroll down and come back!
After I set up my own IMAP server for my e-mail, I began to get error messages from Thunderbird: “Error copying message to sent folder. Retry? OK.” Rather than change my Postfix server (which was advised against by the documentation), I looked for a client-side solution. Retrying is a crap-shoot. Sometimes it copies, but most of the time it just sits there after informing you that:
Unable to connect to your IMAP server. You may have exceeded the maximum number of connections to this server. If so, use the Advanced IMAP Server Settings Dialog to reduce the number of cached connections.
Advanced IMAP Server Settings Dialog? I’ve never heard of that before. Let’s see what about:config has to say. You can find it in Tools->Options… on Windows, or Edit->Options… on other platforms. Once you see the dialog, hit the “Advanced” icon at the top right, then hit the “General” tab in the area below it. You’ll see “Config Editor…”.
I tried setting: mail.imap.max_cached_connections from 5, to 1, to 0. No value fixes it.
I then noticed: mail.server.server2.max_cached_connections And not just that one (I have several IMAP accounts). There were a few others as well. Setting these to 1 HAS solved my problem.
Just make sure all your: mail.server.serverN.max_cached_connections = 1
Now, had I listened to the error message from the start, I would have gone to the account settings for each. Right click on the IMAP account and select properties. Then goes to server settings. You’ll notice an “Advanced” button. Sure enough, you see the text field for the number of cached connections. Of course, if you want to change them all at once, you can use the Config Editor.
Remember, restart Thunderbird for the changes to take effect. Don’t expect miracles until after you’ve relaunched.
The Explanation
IMAP connection caching? Yes, when Thunderbird checks your e-mail over IMAP, it starts up a TCP connection. That’s a 3-way handshake.
- Hello Server!
- Hello Client!
- Hello again Server! (I got your hello)
3 Hello’s = 3 way handshake. OK OK, yes, this is a gross oversimplification. None-the-less, this handshake sequence is considered slow and “expensive.” So instead of saying good-bye after getting your mail, the client will say, “I’ll be back, so leave the line open.” Sounds good, but most servers have limited resources. Once the maximum number of connections is reached, it won’t accept any more. That’s what is happening with Thunderbird here. It’s being told that there is no more room.
So, what limited resource am I talking about? Well, those connections take up memory, especially the secure ones. SSL adds the overhead of a new shared secret (passphrase). That’s not too bad, but it’s more than storing the usual, unencrypted nothing. Even if you don’t use SSL, each connection uses a new port. Every computer has 65535 ports. Depending on the system, approximately 1000 of them are reserved for system calls. The other 64,000 and change are shared among all the services provided by the server. And, yup, you guessed it, each connection uses up a port.
May not seem like a big deal. But say, you have an account. Thunderbird caches 5 connections by default. If you have 5 folders, it will use all 5 connections and cache them. If your e-mail is on a dedicated machine: 64,535/5 = 12,907. Only 13 thousand users can check their mail (if they all have 5 or more folders). If you have a big company, this would be bad if the CEO or POB (pointy haired boss) can’t check his or her e-mail. Most servers will limit you (as did mine and probably yours if you’re reading this article to solve your problem) to 4 connections from the same IP address. While it helps solve the connection volume problem, Thunderbird gets confused.
See, if you need a new connection on the same account, thunderbird will use any active ones. But if you have multiple accounts, Thunderbird assumes the connections are independent. Apparently, this is a mistake.
An Expert Fix
I suggest that Thunderbird take note of refused connections and give up active connections from other accounts if they resolve to the same server. That will expand the already automatic connection cycling feature among connections on the same account to connections on the same client.
