Strange Remoting Error

I'm getting the following errors when I try to make a remote call to an application server I have. The error doesn't always comes up, just seems to be at random times.

Here is the error I'm getting:

Error:   Server stack trace:      
at System.Net.Security.NegotiateStream.ProcessRead(Byte[] buffer, Int32 offset, Int32 count, AsyncProtocolRequest asyncRequest)    
at System.Net.Security.NegotiateStream.Read(Byte[] buffer, Int32 offset, Int32 count)    
at System.Runtime.Remoting.Channels.SocketHandler.ReadFromSocket(Byte[] buffer, Int32 offset, Int32 count)    
at System.Runtime.Remoting.Channels.SocketHandler.Read(Byte[] buffer, Int32 offset, Int32 count)    
at System.Runtime.Remoting.Channels.SocketHandler.ReadAndMatchFourBytes(Byte[] buffer)    
at System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadAndMatchPreamble()    
at System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadVersionAndOperation(UInt16& operation)    
at System.Runtime.Remoting.Channels.Tcp.TcpClientSocketHandler.ReadHeaders()    
at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)    
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)    
Exception rethrown at [0]:      
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)    
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)    
at MyAppServer.SendMail.SendConfirmEmails(Int32 invId, Boolean sendPromotionalPartnerEmail, Int32 refId, String serverSetting)    
at MyWebSite.reg.SendConfirmEmails(Object sendParams) in d:\HTTP\MyWebSite\reg.aspx.cs:line 706

Here is the code that is calling it:

MyAppServer.SendMail appServ= (MyAppServer.SendMail)Activator.GetObject(typeof(MyAppServer.SendMail), "tcp://" + wbAppIP.wvValue + "/SendMail");

sent = appServ.SendConfirmEmails((int)sndParams["InvId"], (bool)sndParams["SendPromo"], (int)sndParams["RefId"], hostEnvironment);

I've stepped through this and made sure that all the variables I'm using have the correct values in them. So, I'm not sure what is causing this problem.

Also, here is the entry in my web.config that allows me to call the AppServer from my website:
I've changed the tcp url to 999.99.999.999:999 for this example, so that I don't give away my app server url in this question text.
            <wellknown url="tcp://999.99.999.999:999/SendMail" type="MyAppServer.SendMail, MyAppServer"/>
            <channel type="System.Runtime.Remoting.Channels.Tcp.TcpChannel, System.Runtime.Remoting" ref="tcp" secure="true" protectionLevel="EncryptAndSign" tokenImpersonationLevel="impersonation" useDefaultCredentials="False" timeout="5" username="My_Services" password="11111111">
                        <formatter ref="binary"/>
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Roshan DavisCommented:
give timeout="5000" for 5 seconds

timeout = 5 means giving timeout of 5 milliseconds I believe

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
quanmacAuthor Commented:
For some reason, I thought that the timeout was in minutes. I'll set it to timeout for 10 seconds and I will let you know if that works.
Roshan DavisCommented:
it should work. All the best!
quanmacAuthor Commented:
Thanks, the error has gone away and it looks like its working.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.