0 votes
by (240 points)
edited by

I have noticed a big difference in performance when using Proxy or not. I have a big Imap mailbox, when I try to find all messages between two dates the response time varies so much.
In both scenaries the message count is always the same: 800 messages.

  • Without Proxy: 120 seconds
  • With Proxy: 22 seconds

Should I have to use proxy for improving the response time? What can I do in environments where I can not set a Proxy?

Thanks in advance.

Applies to: Rebex Secure Mail
by (147k points)
Which kind of proxy do you use? Is it SOCKS4/SOCKS5, HTTP CONNECT, or an SSH tunnel?
by (240 points)

1 Answer

0 votes
by (147k points)

When using SOCKS4/SOCKS5 or HTTP CONNECT proxies, the only difference between a scenario with a proxy and without it is during the Imap object's Connect method. Once a connection is successfully established, all the communication with the IMAP server goes through a TCP socket, and from the client's point-of-view, it's 100% same for both proxied and proxy-less connections. The only difference is the target endpoint of the TCP socket. In both scenarios, the Imap object is behaving identically once the Connect method has finished successfully.

Additionally, unlike HTTP proxies, HTTP CONNECT itself does not perform anything to speed up things - it simply establishes a connection and forwards data packets between the IMAP server and IMAP client, without any processing at all, and without any kind of caching. HTTP CONNECT proxies don't even understand the IMAP protocol, it's all just raw data to them.

This means that if all things were equal, HTTP CONNECT proxies should be slightly slower than direct connections (because of the overhead of forwarding data packets).

It also means that the observed speedup/slowdown is almost certainly not caused by the client, but by something else - for example, when not using a proxy, your firewall or router might be doing some kind of bandwidth throttling, while proxied connections might have a higher priority. Or proxied connection may simply be using a faster network to access the IMAP server. There are dozens of possible causes, but unfortunately, without any knowledge of your network and proxy setup, we can't determine the actual cause.

Please consult your network administrator - the huge difference in observed response time is certainly unusual.

Of course, make sure you are able to consistently reproduce these results to rule out other explanations - for example, it's quite common for a search command to take substantially less time when it's issued a second time because the IMAP server already has parts of the search process cached, or because it has created or optimized it's index.

by (240 points)

Thank you for your reply. I have contacted with my network administrator. He said that we use a SQUID proxy in Linux and we are connecting from a Windows 2008 device to an IMAP server.

As we said in the previous message we notice a big difference when connecting with Proxy or not. It's like when using Proxy the component only does one connection and when not using proxy does multiple connections, one per each message queried.

The source code is the same, the only difference is when stablishing the connection. Here is that part of the code:

internal static void CreateRebexProxy(Rebex.Net.Proxy rebexProxy, ProxyConfiguration proxy)
      //devolver nulo si no se ha establecido el parámetro
      if (proxy == null)

      rebexProxy.ProxyType = Rebex.Net.ProxyType.HttpConnect;
      rebexProxy.AuthenticationMethod = Rebex.Net.ProxyAuthentication.Basic;
      rebexProxy.Host = proxy.Server;
      rebexProxy.Port = proxy.Port.Value;
      rebexProxy.UserName = proxy.UserName;
      rebexProxy.Password = proxy.Password;
      rebexProxy.Domain = proxy.Domain;

What else do you need to know about our network?

by (147k points)
Hello, I can say with confidence that:
1. Our IMAP component does not establish multiple connections. Each successful call to Connect method establishes a single connection, and no additional connections are established anywhere else.
2. Once the Connect method completes, the subsequent behavior of the IMAP in regards to the connection's TCP socket component is 100 % identical in both cases. There is no difference in TCP traffic through connections established through a proxy and connections established directly (only the initial part in the Connect method differs).
All of this can be independently verified using a network protocol analyzer such as Wireshark (www.wireshark.org). A Wireshark log might also make it possible to determine the cause, although this is not guaranteed.
For example, the Squid proxy might force larger send and receive buffer size for the two TCP sockets (a connection to the server and a connection to the client), which might affect speed a lot in some scenarios. To rule out this cause, I have sent a link to hotfix for Rebex Secure Mail to your e-mail that adds Imap.Settings.UseLargeBuffers options - could you please give it a try and let me know whether it makes any difference? (Set Imap.Settings.UseLargeBuffers to true to enable large TCP buffers.)
by (240 points)

Thank you for your reply. I have checked my mailbox but I don't find any link. Please, could you resend it?

by (147k points)
Perhaps it was marked as spam? Anyway, here's the trial hotfix link: http://www.rebex.net/getfile/f79ef01f171e4c2c96a7a5315b1aa390/RebexSecureMail-HotfixBuild5982-Trial-Binaries.zip
If you already have an active Rebex Secure Mail support contract, please let us know at support@rebex.net and we will send you a link to the full version as well.