WCF Service , how to increase the timeout? - wcf

Might seem like a silly question, but everything in WCF seems a lot more complicated than in asmx, how can I increase the timeout of an svc service?
Here is what I have so far:
<bindings>
<basicHttpBinding>
<binding name="IncreasedTimeout"
openTimeout="12:00:00"
receiveTimeout="12:00:00" closeTimeout="12:00:00"
sendTimeout="12:00:00">
</binding>
</basicHttpBinding>
</bindings>
And then my endpoint gets mapped like this:
<endpoint address=""
binding="basicHttpBinding" bindingConfiguration="IncreasedTimeout"
contract="ServiceLibrary.IDownloads">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
The exact error I am getting:
The request channel timed out while waiting for a reply after 00:00:59.9990000. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.
In the WCF Test Client, there is a config icon that contains the run time configuration of my service:
As you can see its not the same values as I've set for it? What am I doing wrong?
<bindings>
<basicHttpBinding>
<binding name="BasicHttpBinding_IDownloads" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="">
<extendedProtectionPolicy policyEnforcement="Never" />
</transport>
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>

In your binding configuration, there are four timeout values you can tweak:
<bindings>
<basicHttpBinding>
<binding name="IncreasedTimeout"
sendTimeout="00:25:00">
</binding>
</basicHttpBinding>
The most important is the sendTimeout, which says how long the client will wait for a response from your WCF service. You can specify hours:minutes:seconds in your settings - in my sample, I set the timeout to 25 minutes.
The openTimeout as the name implies is the amount of time you're willing to wait when you open the connection to your WCF service. Similarly, the closeTimeout is the amount of time when you close the connection (dispose the client proxy) that you'll wait before an exception is thrown.
The receiveTimeout is a bit like a mirror for the sendTimeout - while the send timeout is the amount of time you'll wait for a response from the server, the receiveTimeout is the amount of time you'll give you client to receive and process the response from the server.
In case you're send back and forth "normal" messages, both can be pretty short - especially the receiveTimeout, since receiving a SOAP message, decrypting, checking and deserializing it should take almost no time. The story is different with streaming - in that case, you might need more time on the client to actually complete the "download" of the stream you get back from the server.
There's also openTimeout, receiveTimeout, and closeTimeout. The MSDN docs on binding gives you more information on what these are for.
To get a serious grip on all the intricasies of WCF, I would strongly recommend you purchase the "Learning WCF" book by Michele Leroux Bustamante:
Learning WCF http://ecx.images-amazon.com/images/I/51GNuqUJq%2BL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU01_.jpg
and you also spend some time watching her 15-part "WCF Top to Bottom" screencast series - highly recommended!
For more advanced topics I recommend that you check out Juwal Lowy's Programming WCF Services book.
Programming WCF http://ecx.images-amazon.com/images/I/41odWcLoGAL._BO2,204,203,200_PIsitb-sticker-arrow-click,TopRight,35,-76_AA240_SH20_OU01_.jpg

The best way is to change any setting you want in your code.
Check out the below example:
using(WCFServiceClient client = new WCFServiceClient ())
{
client.Endpoint.Binding.SendTimeout = new TimeSpan(0, 1, 30);
}

The timeout configuration needs to be set at the client level, so the configuration I was setting in the web.config had no effect, the WCF test tool has its own configuration and there is where you need to set the timeout.

Got the same error recently but was able to fixed it by ensuring to close every wcf client call.
eg.
WCFServiceClient client = new WCFServiceClient ();
//More codes here
// Always close the client.
client.Close();
or
using(WCFServiceClient client = new WCFServiceClient ())
{
//More codes here
}

Related

Calling WCF service from excel gives error on received message size

I am calling my WCF service from excel VBA code using moniker string. However, as my service returns large data as response, excel gives error message
"Maximum message size quota for incoming messages (65534) has been exceeded. To increase the quota used the MaxReceivedMessageSize property on the appropriate binding element"
Here is the moniker string:
addrToService = "service4:mexAddress=""net.tcp://localhost/MyApp/API/Excel/ExcelAPIService.svc/mexTCP"", "
addrToService = addrToService + "address=""net.tcp://localhost/PruCapWebCMHost/API/Excel/ExcelAPIService.svc"", "
addrToService = addrToService + "contract=""IExcelAPIService"", contractNamespace=""http://Prucap/Services"", "
addrToService = addrToService + "binding=""NetTcpBinding_IExcelAPIService"", bindingNamespace=""http://MyApp/Services"""
To resolve this, I increased the size in my WCF service's web.config file as shown below:
<netTcpBinding>
<binding name="NetTcpBinding_IPublicService" maxBufferPoolSize="8388608" maxBufferSize="8388608" maxReceivedMessageSize="8388608" portSharingEnabled="true">
</binding>
</netTcpBinding>
<basicHttpBinding>
<binding name="BasicHttpBidning_IPublicService" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:05:00" receiveTimeout="00:05:00" maxReceivedMessageSize="8388608" />
<binding name="BasicHttpBidning_ISecureService" closeTimeout="00:05:00" openTimeout="00:05:00" sendTimeout="00:05:00" receiveTimeout="00:05:00" maxReceivedMessageSize="8388608" />
</basicHttpBinding>
....
<service name="ExcelAPIService" behaviorConfiguration="PublicServiceTypeBehaviors">
<endpoint address="" bindingNamespace="http://MyApp/Services" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IPublicService" contract="API.Service.ExcelAPI.IExcelAPIService" name="NetTcpBinding_IExcelAPIService" />
<endpoint address="" bindingNamespace="http://MyApp/Services" binding="basicHttpBinding" bindingConfiguration="BasicHttpBidning_IPublicService" contract="API.Service.ExcelAPI.IExcelAPIService" name="BasicHttpBidning_IExcelAPIService" />
<endpoint address="mex" bindingNamespace="http://MyApp/Services" binding="mexHttpBinding" contract="IMetadataExchange" />
<endpoint address="mexTCP" bindingNamespace="http://MyApp/Services" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
</service>
According to various forums on this topic, the above solution should work. But this does not work in my case when called from excel. Is there anything I need to do from excel side to set the maxReceivedMessageSize? If yes then how can I do this using VBA code?
Additional information:
I use Office 2010 (with VBA), Windows 7 Prof, 64bit OS
The maximum size must be set by the client as well as the server. However, the service moniker form you are using does not support specifying this parameter.
From first hand experience I can tell you, using monikers may seem appealing at first, since it allows you to call services from VBA with minimal coding, but it is very limited in what it can do. I discovered, as no doubt you are in the process of dicovering as well, the best way to approach this is to build a proper WCF client - probably in .NET - and call the client class from your VBA, or even Excel directly.
If you are trying that and are still having trouble, please start a new thread so you can post your code, and more fully explain what you have tried, and what the problem is.
You should set maxReceivedMessageSize="2147483647" to increase message size.
Try increasing message size like:
<binding maxBufferSize="2147483647"
maxBufferPoolSize="2147483647"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="2147483647"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="2147483647"
maxNameTableCharCount="2147483647" />
</binding>
--OR
<basicHttpBinding>
<binding name="BasicHttpBinding_IManagementService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="2147483647" maxBufferPoolSize="524288" maxReceivedMessageSize="2147483647"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="128" maxStringContentLength="2147483647"
maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
refer WCF Error "Maximum number of items that can be serialized or deserialized in an object graph is '65536'"
Wcf-The maximum message size quota for incoming messages (65536) has been exceeded?
UPDATE
You also can change endpoint/service behavior programatically.
Refer links:
How to: Specify a Service Binding in Code
How to: Programmatically Configure a WCF Endpoint
Update2:
Sorry Anil, Previously I totally overlook you are doing this in excel.
The easiest way for your scenario to use WCF service from VB6 is to create a .Net ComObject wrapper for the service client. Then in VB6 all your are doing is a create object and calling some methods on the object. All the WCF work takes place in the .Net com object.
Simply create the WCF client to the service in a separate project as described in this link. Register the .NET assembly as a type library which you would then link from the VB6 app : link.
Sources:
Using WCF in VB6
Integrating WCF Services with COM+
Communicate with WCF Windows Service in VB6?
Hope it helps. :)

WCF: Streamed TransferMode and Method Return Types other than Stream and Message

I have services that return large objects, default transfermode (buffered) doesn't suit to our requirements.
Actually the service is written already and the project team is experiencing out of memory exceptions and slow performance intermittently. Now this needs to be fixed with some patching, rewrting all the services is not an option as the project team is nearing a delivery.
I have an understanding that changing the transfermode to StreamedResponse/Streamed may help in a big way + choosing net.tcp instead of http bindings (intranet application with thick client). I need to know whether I will get benefit for all the operationcontracts or only those, which return Stream/Message.
I created a little sample to check if it has any impact on other return types (DataTable/DataSet) and it seems it effects all the return types including DataTable/DataSet. I checked WCF HttpTransport: streamed vs buffered TransferMode and looks like the same behavior is experienced by others as well.
The only thing missing here is some concrete documentation which clearly states that it effects all the operationcontracts irrespective of return type. I need some references so that I can push my recommendation for this chnage.
Please do not suggest not to return DataTable/DataSet from the services; I know its a bad-bad practice and should be avoided all the times but in this case the services were already there and I can't ask them to change everything at this moment.
Update:
My perception is based on following test
My interface
[ServiceContract]
public interface IMediaManager
{
[OperationContract]
Stream Play(int mediaId);
[OperationContract]
DataSet GetJunk();
}
My Implementation
public class MediaManager : IMediaManager
{
public Stream Play(int mediaId)
{
String path = GetMedia(mediaId);
FileStream fStream = new FileStream(path, FileMode.Open, FileAccess.Read,FileShare.Read);
return fStream;
}
public DataSet GetJunk()
{
return GetLargeJunkDataSet20PlusMegs();
}
}
Hosted over IIS - Non Http WAS, Server Configuration File (Tags stripped off, only relevant ones)
<system.serviceModel>
<services>
<service name="MediaService.MediaManager" behaviorConfiguration="MediaServiceBehavior">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:9876/MediaService/MediaManager.svc" />
</baseAddresses>
</host>
<endpoint address="" binding="customBinding"
bindingConfiguration="StreamedTcpBinding" name="MediaManagerTcp"
contract="MediaService.IMediaManager" />
<endpoint address="mexTcp" binding="mexTcpBinding" name="mexTcp"
contract="IMetadataExchange" />
</service>
</services>
<bindings>
<customBinding>
<binding name="StreamedTcpBinding" sendTimeout="00:10:00" receiveTimeout="00:10:00">
<binaryMessageEncoding />
<tcpTransport transferMode="Streamed" portSharingEnabled="true" />
</binding>
</customBinding>
</bindings>
Client Configuration File (Only relevant tags)
<binding name="MediaManagerTcp" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
transferMode="Streamed" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="2147483647"
***maxBufferSize="1001"*** maxConnections="10" maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
If you see above, the maxBufferSize is 1001 bytes, however the actual message would be 20+ mb. This makes me think the Streamed is working for DataSet as well (everything, not only limited to Stream and Message). I hope my interpretation is correct of maxBufferSize (its the maximum size which will be received in one chunk).
I must also add that the same method fails if I switch to Buffered mode.
I hope my analysis makes sense, if not clear then please let me know and I shall try again?
I will repeat my question again so that it doesn't get lost :)
The only thing missing here is some concrete documentation which clearly states that it effects all the operationcontracts irrespective of return type. I need some references/experiences so that I can push my recommendation for this chnage.
Any help will be much appreciated!
Thanks,
A
Finally found something relevant.
The DataSet is an inherited child of IXMLSerializable, hence its a candidate for streaming. Following is picked from MSDN (Streaming Message Transfer)
Operations that occur across a streamed transport can have a contract with at most one input or output parameter. That parameter corresponds to the entire body of the message and must be a Message, a derived type of Stream, or an IXmlSerializable implementation. Having a return value for an operation is equivalent to having an output parameter.
and DataSet is an implementation of IXmlSerializable . DataSet's definition
[SerializableAttribute]
public class DataSet : MarshalByValueComponent, IListSource,
IXmlSerializable, ISupportInitializeNotification, ISupportInitialize,ISerializable
Thanks,
A

WCF consume by dotnet winfom client and config entry

i am new in WCF but i am bit familiar with web service (ASMX file)
i have couple of question on wcf client config entry
when we create any web service (ASMX) proxy then nothing add in config file like below entry but in case of WCF the below entry adds. i just need to know the significant of the below entry.
1) if i delete these below entry then what will happen....can't i call the service from the client side?
2) just tell me when we call web service from client side then how do i say that which endpoint address my service will use to call service if there are more than one endpoint address added in client side ?
3) how do i explicitly mention web service url from cient side when i will make a service call?
<system.serviceModel>
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_ICommService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:00:05"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost/CommService/"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_ICommService"
contract="Services.ICommService" name="WSDualHttpBinding_ICommService">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Yes these are important configuration that are required by WCF. Either you provide it through config file or your code.
1) You need to provide it some where. If you take them fro config . You should be doing it in code.
2) WCF has basic rule of ABC . Address , Binding and Contract. Again you don't have to say anything if its already in your config file.
For multiple clients . You can also mention the endpoint name from your config file. ForExample
MyClient someClientObject = new MyClient("WSDualHttpBinding_ICommService");
3) By default, when you Add Service Reference operation, WCF Runtime gets you a client side proxy .
You can do it like this in a simple way. ParameterLess.
MySVCClient svcproxy = new MySVCClient ();
You need to have entry with your service contract .
You can also use as follows with constructor ... using endpoint Adddress and Bidning etc.
BasicHttpBinding myBinding= new BasicHttpBinding(SecurityMode.None);
EndpointAddress endpointAdd= new EndpointAddress("http://localhost/CommService/");
MySVCClient svcproxy = new MySVCClient (myBinding, endpointAdd);
Since you are defining everything in code here. You don't need anything in config file.

timeoutexception or default connection limit on wcf?

I firstly launched my subscriber for my WCF service and proceed to publish a posting from my publisher. My subscriber is able to receive the posting.
Secondly I closed my FIRST subscriber and open it again to subscribe to the same service which is so called the SECOND subscriber that has subscribed to the service. And once again, it is able to receive a posting.
Once I repeat this for the third time, there would be a exception of
The message could not be transferred within the allotted timeout of 00:01:00. There was no space available in the reliable channel's transfer window. The time allotted to this operation may have been a portion of a longer timeout.
Summary :
On first client, SUBSCRIBED , everything works fine
Closes first client
On the cilent AGAIN , (meaning second connection on the same service(?)) , everything works fine
Closes "second client"
Opens the client for the THIRD time, error occurs
From what I have researched so far, I have seen that in this question, it mentioned that the default connection limit is 2?
WCF Service Throttling
Is that the issue that is causing my error? IF yes, is it possible to adjust the limit of the connection and how?
Pretty new in the WCF area and welcome anybody to give me their opinion.
Thanks!
EDIT
Tried using UseSynchronizationContext = false on my client. As everytime a posting is sent, my PostReceived() method for my subscriber includes opening a popup windows form containing the information of the posting. When using UseSynchronizationContext = false, the windows form would not be able to open properly(an error here).
Anyone has any idea how to fix that or have any alternate solutions?
EDIT 2
Been reading around lots of WCF connection related stuffs and found out that most people are trying to toggle the maxConnections variable or related in their config files. My question is the only config files I have is in my client and none for my Service project. Is it necessary for me to add a config file for my service project?
As the "connection limit"(?) is 2, I tried the method of unsubcribing it when the client exits the application but that doesn't work and gives me and error. I have posted a question on the error that I received.
https://stackoverflow.com/questions/8395525/objectdisposedexception-on-wcf-service
Config Codes for Client side added :
<system.serviceModel>
<diagnostics performanceCounters="All" />
<bindings>
<wsDualHttpBinding>
<binding name="WSDualHttpBinding_IPostingContract" clientBaseAddress="http://localhost:8000/wcfClient/" closeTimeout="00:01:00"
openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:10:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" />
<security mode="Message">
<message clientCredentialType="Windows" negotiateServiceCredential="true"
algorithmSuite="Default" />
</security>
</binding>
</wsDualHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8888/PostingContract/Posting"
binding="wsDualHttpBinding" bindingConfiguration="WSDualHttpBinding_IPostingContract"
contract="IPostingContract" name="WSDualHttpBinding_IPostingContract">
<identity>
<userPrincipalName value="##" />
</identity>
</endpoint>
</client>
</system.serviceModel>
Would someone advise me if I have done anything wrong for my service part with regards to the behaviors or the config files. Appreciate a million. Thanks!
EDIT 3
Manage to play around with the service behavior. For the behavior, I changed the InstanceContextMode to single.
InstanceContextMode = InstanceContextMode.Single
and that actually allowed me to launch more than 2 connections of my windows form app. However if I do that, If I had launch 2 connections beforehand, for the third connection it will receive 3 popups, and subsequently for the forth connection, it will receive 4. When it is suppose to receive 1.
would that help to add UseSynchronizationContext = false on the client subscriber class
for e.g.
[CallbackBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant,
UseSynchronizationContext = false)]
The reason might be of the dealocking callback
similiar post here WCF: Having trouble with one-way callbacks

WCF Client - only first 255 bytes of stream returned from WCF service contain values

I have been tasked to look after an ASP.Net WebForms application that communicates with a WCF service hosted by a Windows service. The binding used for the service is netTcpBinding.
The service exposes methods to Upload and Download ‘files’. The user select to upload a file and the HttpPostFile.InputSteam is passed directly to the service as a parameter in the service 'Upload' method. The service saves the stream as a byte array to the database [database field data type is varbinary (max)].
The file download data flow is essentially the reverse process. The bytes are retrieved from the database; loaded into a MemoryStream in the WCF service; and then returned to the Web Application.
I have captured the data contained in the streams (sent / received) at each step in the above operations - on the client (web app) and the service. I have looped through and written out to a flat file the bytes contained in each stream.
The byte array in each case is identical [byte value; and number of bytes in the stream] except for the File Download operation. At the point where the stream is returned to the Web Application from the WCF service. Here the number of bytes received is correct but only the first 255 bytes are populated. The values of the remaining bytes are zero
I have made a host of experimental changes to the binding values - in both the client at service - as I believe that the problem must lie here. To date I have not influenced the status of the bytes returned in any way. The logs for the Client and service do not show any that any exceptions are thrown or any other problems.
I do not have much experience in setting the correct combinations of binding (and other configuration) attributes for Client and Server applications – having relied on defaults in the past. We need the service and client to be configured to transfer the maximum allowable file size. Unfortunately I cannot use MTOM.
This post and links, did not offer me any insight. So far I have found no other information that helps.
Hopefully someone can assist me with what the issue might be. Below are the bindings that I am using:
Client [web.config]:
<bindings>
<netTcpBinding>
<binding name="TCP"
closeTimeout="00:01:00"
openTimeout="00:10:00"
receiveTimeout="00:01:00" sendTimeout="00:01:00"
transferMode="Streamed"
maxBufferPoolSize="512"
maxBufferSize="2147483647"
maxConnections="10"
maxReceivedMessageSize="2147483647">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="2147483647" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
Service:
<netTcpBinding>
<binding name="netTCP"
closeTimeout="00:01:00"
openTimeout="00:01:00"
receiveTimeout="00:01:00" sendTimeout="00:01:00"
transferMode="Streamed"
listenBacklog="30"
maxBufferPoolSize="512"
maxBufferSize="2147483647"
maxConnections="30"
maxReceivedMessageSize="2147483647"
portSharingEnabled="true">
<readerQuotas maxDepth="32"
maxStringContentLength="2147483647"
maxArrayLength="2147483647"
maxBytesPerRead="4096"
maxNameTableCharCount="2147483647" />
</binding>
</netTcpBinding>
Silly me. I think I have got it.
The bindings were OK. I was not dealing with reading the bytes correctly from the stream into the buffer on the client.