0

I have a WCF service that works fine with an app.config file. I decided to move this app.config stuff to the code so I have better control. I tried the following:

string localIP = GetLocalIP();

int PrimaryPort = 9900;
Uri PrimaryUri = new Uri(String.Format("net.tcp://{0}:{1}/", localIP, PrimaryPort));

int MetaPort = 9901;
Uri MetaUri = new Uri(String.Format("http://{0}:{1}/", localIP, MetaPort));

AES_MarketDataService aes = new AES_MarketDataService();

using (ServiceHost aesHost = new ServiceHost(aes, MetaUri, PrimaryUri))
{
    NetTcpBinding PrimaryBinding = new NetTcpBinding();
    PrimaryBinding.Name = "AES";
    PrimaryBinding.ReceiveTimeout = new TimeSpan(0, 0, 10);
    PrimaryBinding.Security.Mode = SecurityMode.Transport;
    PrimaryBinding.ReliableSession.Enabled = true;

    ServiceMetadataBehavior mexBehavior = new ServiceMetadataBehavior();
    mexBehavior.HttpGetEnabled = true;

    aesHost.Description.Behaviors.Add(mexBehavior);
    aesHost.AddServiceEndpoint(typeof(IAES_MarketDataService), PrimaryBinding, "AES");
    aesHost.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");

    aesHost.Open();

    Console.WriteLine("Host started at {0}: svc={1}, meta={2}", DateTime.Now, PrimaryUri.AbsoluteUri, MetaUri.AbsoluteUri);

    Console.ReadLine();
}

This works, but for some reason, the client faults a few seconds after its first call to the service. There is no exception on the server side, and if I restart my client, I am perfectly able to make another call (which will again fault the client after a few seconds).

What is this code missing that the app.config file is not?

user3685285
  • 6,066
  • 13
  • 54
  • 95
  • Show us client side code and fault details. – Pankaj Kapare Mar 07 '16 at 16:05
  • That's what I can't figure out. I only know it's faulting because it raises the OnFaulted event, which doesn't give any information. Meanwhile, the server is completely fine. I'm also using all one-way operations, so I don't know where on the client it is faulting. – user3685285 Mar 07 '16 at 19:00

0 Answers0