Archived Forum Post

Index of archived forum posts

Question:

100% CPU with C# IMAP Chilkat and Windows Service

May 19 '14 at 00:48

Using IMAP Chilkat 9.4.1 (either x86 or x64) on Production as part of a Windows Service - Few days after starting the service, the service seems to be stuck, consuming 100% CPU, all the time. Basically, the service connects to an Email Provider and parses emails.

For example, it uses this sample: http://www.example-code.com/csharp/imap_markAsRead.asp

I've tried calling Dispose() and assigning the Imap Connection object to null, as well as using GC.Collect(). Nothing seems to work.

The service itself can be multi-threaded - each thread has its own Imap Connection object.

Also, I've tried using only 1 thread - and it still hangs.

The service doesn't use much RAM - only CPU issue.

What could be the issue here?

Additional information: As suggested, I'm running debug logger with Chilkat.

In the meantime, at the service application logs every time it hangs - the log stops at a specific point: several milliseconds right after disconnecting from the Mail Server (Google is the mail service provider). Code Sample where it seems to hang according to the application service logs:

        if (imapCon != null)
        {
            if (imapCon.IsLoggedIn())
            {
                imapCon.Logout();
            }

            if (imapCon.IsConnected())
            {
                imapCon.Disconnect();
            }

            imapCon.Dispose();
            imapCon = null;  
        }

[IMAP CHILKAT DEBUG LOGS] Updating Logs - We use an Amazon VM and VPC and the network might fail, but the Chilkat code should not get stuck on 100% CPU - please review the following information from the Chilkat debug logs - the service reached 100% CPU and got stuck:

ListMailboxes:

DllDate: May  6 2014

ChilkatVersion: 9.5.0.38

UnlockPrefix: SNILIKIMAPMAIL

Username: WIN-OCJD4A0985E:SYSTEM

Architecture: Little Endian; 64-bit

Language: .NET 4.5 / x64

VerboseLogging: 0

listMailboxes:

    bSubscribedOnly: 0

   reference:

    mailbox: *

    Escaping quotes and backslashes in mailbox name...

    utf7EncodedMailboxPath: *

    getCompleteResponse:

            WindowsError: An established connection was aborted by the software in your host machine.

            WindowsErrorCode: 0x2745

            numBytesRequested: 5

            Failed to receive data on the TCP socket

            Failed to read beginning of SSL/TLS record.

            Failed to read incoming handshake messages. (3)

            (leaveContext)

        Client handshake failed. (3)

        (leaveContext)

    ConnectFailReason: 0

    (leaveContext)

failReason: 0

connect failed.

(leaveContext)

Login:

DllDate: May  6 2014

ChilkatVersion: 9.5.0.38

UnlockPrefix: SNILIKIMAPMAIL

Username: WIN-OCJD4A0985E:SYSTEM

Architecture: Little Endian; 64-bit

Language: .NET 4.5 / x64

VerboseLogging: 0

login: ******************

ConnectionType: SSL/TLS

Error sending on socket (1)

SocketError: WSAECONNABORTED An established connection was aborted by the software in your host machine.

For more information see this Chilkat Blog post: http://www.cknotes.com/?p=91

send_size: 90

Failed to send TLS message.

Failed to send LOGIN command

Failed.

Answer

You'll need to do some basic debugging of your Windows Service to determine whether the 100% CPU utilization and hang occurs within a Chilkat method call or not. If NOT, then it's just your Windows Service this is spinning its wheels. If it is within Chilkat, (1) test with the latest version (v9.5.0) and (2) use the DebugLogFilePath property to find out what's going on within the particular call that spins/hangs.