2

I am currently working on a WCF service and have a small issue. The service is a Polling Duplex service. I initiate data transfer through a message sent to the server. Then the server sends large packets of data back through the callback channel to the client fairly quickly.

To stop the I send a message to the sever telling it do stop. Then it sends a message over the callback channel acknowledging this to let the client know.

The problem is that a bunch of packets of data get buffered up to be sent through the callback channel to the client. This causes a long wait for the acknowledgement to make it back because it has to wait for all the data to go through first.

Is there any way that I can clear the buffer for the callback channel on the server side? I don't need to worry about loosing the data, I just need to throw it away and immediately send the acknowledgement message.

braX
  • 9,702
  • 5
  • 16
  • 29
thecaptain0220
  • 1,978
  • 4
  • 27
  • 49
  • I still haven't come up with a good solution on this one. I'm really not even sure where all the data is getting buffered. The server is sending data, then I tell it to stop, I see that happen on the server side, but the client continues to get data for a few seconds after that. If I slow down the sending I don't have issues. The problem here though is that connection speeds will vary, I feel like this will need to be throttled based on the connection. Even if I could tell when the buffer is empty that would help, then I could store the data myself send when it was. – thecaptain0220 May 10 '12 at 15:37

1 Answers1

1

I'm not sure if this can lead you into the correct direction or not... I have a similar service where when I look in my Subscribe() method, I can access this:

var context = OperationContext.Current;
var sessionId = context.SessionId;
var currentClient = context.GetCallbackChannel<IClient>();
context.OutgoingMessageHeaders.Clear();
context.OutgoingMessageProperties.Clear();

Now, if you had a way of using your IClient object, and to access the context where you got the instance of IClient from (resolve it's context), could running the following two statements do what you want?

context.OutgoingMessageHeaders.Clear();
context.OutgoingMessageProperties.Clear();

Just a quick ramble from my thoughts. Would love to know if this would fix it or not, for personal information if nothing else. Could you cache the OperationContext as part of a SubscriptionObject which would contain 2 properties, the first being for the OperationContext, and the second being your IClient object.

Richard B
  • 1,581
  • 1
  • 15
  • 30
  • This seems like it could be the right direction. I keeping the client and OperationContext around but when I go to clear the OutgoingMessageHeaders it says the count is 0 before clearing. I'll mess around with it some more and let you know if I find anything out. – thecaptain0220 May 07 '12 at 20:50