Reonekot
Reonekot

Reputation: 412

Slow(ish) WCF connection speed with netTcpBinding

I know this subject has been brought up quite a few times here on SO, but I can’t find the exact answer I’m looking for regarding expected connection latency from WCF.

Basically I have a self hosted WCF service (server), which does alarm handling in a factory environment. Latency needs to be minimized end-to-end for these alarms, so I’m looking into connection times. The alarms are delivered in different ways, one of them is through a netTcpBinding WCF service. Another service application (client) which atm. is running on the same server is using the server to deliver the alarms through this binding which generally works well.

My problem is the initial connection latency from the client as the IChannel.Open() call takes between 100-500 ms. with an average of ~300 ms. which seems very high for creating a connecting on the same server through TCP/IP. (A quick test with raw sockets I get ~1ms connection speed.)

In the client I create the ChannelFactory manually once on start-up and reuses that to “channelFactory.CreateChannel()” when I need to send an alarm. After this I explicitly Open() the IChannel, which is the time I’m worried about. The service sends a batch of alarms and after that the IChannel is closed and disposed. A quick reconnect takes 0 ms., but often it takes 3-5 minutes between alarms and reopening after a “long” pause is slow considering I run without security etc. enabled right now for testing.

My binding configuration is pretty basic:

<binding name="AlarmService_NetTcpBindingConfig"
            hostNameComparisonMode="StrongWildcard"
            closeTimeout="00:01:00"
            portSharingEnabled="false"
            listenBacklog="20"
            maxConnections="50"
            transactionFlow="false"
            transferMode="Buffered"
            >
    <security mode="None">
        <message clientCredentialType="None" />
        <transport clientCredentialType="None" protectionLevel="None" />
    </security>
    <reliableSession enabled="false" />
</binding>

So basically the question (besides vending frustration :) ) is, if this is the connection latency I can expect through WCF netTcpBinding?

The only thing I can think of that I haven’t tried yet, is to follow the “Configuring the Net.TCP Port Sharing Service” article (http://msdn.microsoft.com/en-us/library/aa702669.aspx) and see if that helps any. Could connection sharing (though disabled for the binding as above) be the problem? Anyone else looked into connection speed/latency?

Upvotes: 3

Views: 2535

Answers (1)

chandmk
chandmk

Reputation: 3481

You can try proxy pooling. Here is a sample

nettcp port sharing service must be started if you are hosting the service on IIS. It allows you to share a single port among multiple wcf services. I don't think it has any bearing on performance of opening a channel

Upvotes: 1

Related Questions