Search code examples
wcfazure-service-fabricwcf-bindingservice-fabric-stateless

Hosting WCF service in Azure Service Fabric


I have a set of WCF services that I would like to migrate to Azure Service Fabric. I am creating a service fabric stateless service for each WCF service, and reference the WCF service library and contracts from my fabric service. My aim is zero code change to existing WCF service libraries and contracts. The fabric service acts like wrappers.

I am successful for simple services, I put the WCF service configurations into the app.config file of fabric service (.NET framework), the system.configuration.configurationmanager calls in existing wcf code seems to work fine.

However, many of the more complicated services that I am trying to migrate contains code that calls other WCF service using ChannelFactory. I wonder will this work? Does Azure Service Fabric allow its service to make external communication calls through ChannelFactory?

How can I read the WCF tracing logs in service fabric? There is no local drive to store the log files?

I am also getting generic connection closed error when a client calls wcf service in the fabric.

[EDIT] The load balancer was configured but the client still can't get through:


Could not connect to net.tcp://10.0.0.6:9012/. The connection attempt lasted for a time span of 00:00:21.0433425. TCP error code 10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 10.0.0.6:9012. 
Server stack trace: 
   at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
   at System.ServiceModel.Channels.BufferedConnectionInitiator.Connect(Uri uri, TimeSpan timeout)
   at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)
    Inner Exception:
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 10.0.0.6:9012
   at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
   at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
   at System.ServiceModel.Channels.SocketConnectionInitiator.Connect(Uri uri, TimeSpan timeout)

Solution

  • Does Azure Service Fabric allow its service to make external communication calls through ChannelFactory?

    • Service Fabric does not block you from making calls across the network. Do make sure you declare an endpoint in the service manifest, so the port is reserved for the calls.

    How can I read the WCF tracing logs in service fabric? There is no local drive to store the log files?

    • You're running on virtual machines which have a data and a temp drive. However, I recommend using storage away from the cluster to hold log files, to keep them safe as the cluster is scaled down (e.g.).

    I am also getting generic connection closed error when a client calls wcf service in the fabric.

    Did you configure the Azure Load Balancer to forward traffic to the cluster?

    Did you consider running the WCF services as Windows Containers? This way you might not need to create SF services at all.

    Please note, that it appears that WCF does not have a bright future ahead.