I am writing a Windows Service connects to a WCF Service. I can modify both of them. The WCF service is a mail gateway with one SendMail method with many parameters. Now the main problem is that opening a proxy to the WCF service ( proxy = new ServiceReference1.MailServiceClient(); proxy.Open(); ) costs 20 seconds to complete. So I decided to open a proxy in the begining of the Windows Service, and keep it open while the service is running. Now when I invoke the SendMail method I get this exception:
System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. ---> System.ServiceModel.FaultException: The message could not be processed. This is most likely because the action 'http://tempuri.org/IMailService/SendMail' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding.
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.ProcessReply(Message reply, TimeSpan timeout, SecurityProtocolCorrelationState correlationState)
at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
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 SMTPService.ServiceReference1.IMailService.SendMail(String encoding, String server, Int32 port, Boolean htmlmail, String sender, String recipient, String subject, String body)
at SMTPService.SMTPTest.timer2_Tick(Object sender, EventArgs e)
It says "increase the Receive timeout on the service endpoint's binding" but in the web.config the receiveTimeout is infinite (24.20:31:23.6470000). I attached the WCF's web.config file. web.config.txt