views:

58

answers:

0

I have a WCF service that I am self-hosting. It was working fine apart from being slow when the InstanceContextMode was set to PerCall. (the constructor is quite heavy so that makes perfect sense) I set the InstanceContextMode to Single, and now it works fine, after the service has started up. However, if the service is still starting up I am getting errors about the end-point not being found. This didn't happen when I was running in PerCall mode. Is there any way I can make the request wait longer for the service to start up? I have tried setting OpenTimeout, ReceiveTimeout and SendTimeout on the binding, but to no avail.

This is my calling code:

try
{
    ChannelFactory<IGatewayService> scf;
    var binding = new NetTcpBinding();
    binding.Security.Mode = SecurityMode.None;
    scf = new ChannelFactory<IGatewayService>(binding, "net.tcp://" + settings.GatewayHost + ":" + settings.GatewayPort);
    IGatewayService s;
    s = scf.CreateChannel();
    result = s.Submit(taskToSubmit);
    (s as ICommunicationObject).Close();
}
catch (Exception exc)
{
    if (log.IsErrorEnabled) { log.Error("Error submitting task to Gateway", exc); }
}

PS. I'm a WCF-noob, but I'm sure you all figured that out by now ;)