SMTP: Rebex.Net.SmtpException: An existing connection was forcibly closed by the remote host.

0 votes
asked Sep 4 by yksharan (120 points)
edited Sep 4 by yksharan

We send mail from two different modules. One is while configuration/setup and another is when you select the file and send mail to addresses.

Configuration is success. But actual send mail is failing.

wireshark network trace says:
93 34.113000 IPADDRESS1 IPADDRESS2 SMTP 100 [TCP Spurious Retransmission] S: 354 Start mail input; end with .

Actual exception:
2017-08-31 17:01:38 ERROR Smtp(4) Info: Rebex.Net.SmtpException: An existing connection was forcibly closed by the remote host ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.ReceiveNoCheck(Byte[] buffer, Int32 index, Int32 request, SocketFlags socketFlags)
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at Rebex.Net.ProxySocket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at Rebex.Net.SmtpSocket.Receive()
at Rebex.Net.SmtpSocket.ReadLine(String& response)
at Rebex.Net.SmtpSocket.Read()
at Rebex.Net.Smtp.ReadResponse(Int32 success, Boolean blocking)
at Rebex.Net.Smtp.SendData(StuffingStream ss)
at Rebex.Net.Smtp.SendPipelining(Boolean chunking, String[] to, StuffingStream ss, String rcptToParameters)
at Rebex.Net.Smtp.SendInternalInner(String from, String[] to, String envelopeID, Stream message)
at Rebex.Net.Smtp.SendInternal(MimeMessage mail, Stream input, MailAddress sender, MailAddressCollection to)
at Rebex.Net.Smtp.Send(MailMessage mail, String sender, String recipients)
at Rebex.Net.Smtp.Send(MailMessage mail)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Rebex.Net.RebexAsyncResult.Runner()
at Rebex.Net.RebexAsyncResult.SimpleThreadPool.Runner()

at Rebex.Net.Smtp.ReadResponse(Int32 success, Boolean blocking)
at Rebex.Net.Smtp.SendData(StuffingStream ss)
at Rebex.Net.Smtp.SendPipelining(Boolean chunking, String[] to, StuffingStream ss, String rcptToParameters)
at Rebex.Net.Smtp.SendInternalInner(String from, String[] to, String envelopeID, Stream message)
at Rebex.Net.Smtp.SendInternal(MimeMessage mail, Stream input, MailAddress sender, MailAddressCollection to)
at Rebex.Net.Smtp.Send(MailMessage mail, String sender, String recipients)
at Rebex.Net.Smtp.Send(MailMessage mail)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean verifyAccess, StackCrawlMark& stackMark)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
at Rebex.Net.RebexAsyncResult.Runner()
at Rebex.Net.RebexAsyncResult.SimpleThreadPool.Runner()

Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Sep 4 by Lukas Pokorny (86,990 points)

Some server have been observed to have troubles with SMTP's "pipelining" and "chunking" extensions. Please try to disable them before calling the Send method and let us know whether this has any effect:

smtp.EnabledExtensions &= ~(SmtpExtensions.Pipelining | SmtpExtensions.Chunking);
smtp.Send(...);
commented Sep 4 by yksharan (120 points)
There are other devices working good with the server. So I dont think this is an issue with server.
Are there any other steps that I can try at client place?
commented Sep 4 by Lukas Pokorny (86,990 points)
This looks like a connectivity issue that is unlikely to be caused by the client or the server alone. These issues are usually caused by a combination of multiple factors, possibly including network devices along the way as well. Turning off client-side options that are known to occasionally cause problems is recommended as the first step in finding out the cause of the issue - it would be very useful to know what effect this has.
commented Sep 4 by yksharan (120 points)
Thank you for the reply. I have got one question for this comment, if this was connectivity issue then it was not supposed to send the mail from setup/configuration page too. Why do you think it works there?

Additional info if needed.

Command in Setup Page:
rebexSmtpClientInstance.Send(rebexMailMessage);

Command in SendToMail:
IAsyncResult res = rebexSmtpClientInstance.BeginSend(rebexMailMessage, null, null);

For setup, we dont send any attachment. Just plain text.

Thanks,
Sharan
commented Sep 4 by Lukas Pokorny (86,990 points)
I'm unable to tell without additional information - there was most likely some difference in those two operations. If you would like us to look into this, please send us (1) a Wireshark log showing the successful send operation; and (2) a Wireshakr log showing the failed send operation.
...