This project is read-only.

Connection Forcibly Closed by Remote Host

Sep 10, 2013 at 7:29 PM
Edited Sep 10, 2013 at 7:32 PM
I have a routine that creates the Imap4Client, connects to server, processes email and then disconnects. However, every other time the routine runs, I get the following exception:
"Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host." The inner exception SocketErrorCode is coming back as: ConnectionReset {10054}

I've tried using .Close() and/or the .Disconnect() methods and even nothing at all. Can't seem to isolate the cause. I'm using VB.NET 4.0. Any ideas? Basic code structure below. TIA
 Using imap As New Imap4Client()
                imap.ConnectSsl("", 993) ' get exception every other time this line hits
            Catch ex As Exception
                Exit Sub
            End Try
            ....... more code ......

            'imap.Disconnect() ' tried alone
            'imap.Close() 'tried alone
End Using