3

While I'm making SOAP or REST invocations to WCF, I'd like to have the channel stack on either end (client and server) record the on-the-wire size of the data received. So I'm guessing I need to add a custom behavior to the channel stack on either side. That is, on the server side I'd record the IP-header advertised size that was received (cumulatively, until all packets for that message are received). On the client side I'd record the IP-header advertised size that was returned from the server (same summation process).

But this presupposes that this information is visible to a custom WCF behavior at the channel stack level. Perhaps it is only visible at the level of ASP.NET (at a layer beneath WCF)? Or perhaps WCF already collects this "total message size" info, and I can simply access a property?

In short, does anyone have any further insight on if and how this information is accessible? I must qualify that this "size" data will be collected in a production environment, as part of regular business logic calls. Thus I am not interested in the solutions proposed elsewhere.

This question is related to my earlier bandwidth question.

Community
  • 1
  • 1
Brent Arias
  • 29,277
  • 40
  • 133
  • 234
  • I am not sure that you can tap in so deep into the transport protocol (TCP) with WCF. It should be pretty easy to collect the actual payload size, however. Is that what you are after? – Strelok May 26 '10 at 02:13
  • I will settle for payload size, if that is all I can get (I'd probably add in an estimated on-the-wire overhead size, to include the rest of packet size). – Brent Arias May 26 '10 at 02:30

3 Answers3

7

If you set up WCF tracing and message logging, you can inspect the svclog file with the WCF Service Trace Viewer and find the HTTP request content length in that message log:

alt text

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • Since I will be trying to capture this information in a production environment, I will not be able to turn on the tracing feature. However, if I could collect the same "Content-Length" from a custom behavior I add, then that might be what I need. – Brent Arias May 26 '10 at 17:01
1

I think the only place where you could potentially get this information (or as close to it as possible) would be with a custom MessageEncoder that wrapped one of the system-provided ones and recorded that information.

It wouldn't be very hard to do, I think, but it would be annoying to hook as you'd need to use custom bindings for that, I think (or there might be a way to hook it in with a behavior, not sure).

Might be worth pointing out that this would still leave out some on-the-wire data like HTTP headers and such that are sent by the transport but never actually part of the message itself.

tomasr
  • 13,683
  • 3
  • 38
  • 30
0

I got the message size by using Fiddler. This seemed like the most unobtrusive way as it requires no changes to your app or configs.

Just run the tool, make the request and read the statistics Bytes Received

The only other thing you may have to do is decode the message body if it's encoded. When inspecting the request there's a message Response body is encoded. Click to decode. To do this.

robasaurus
  • 1,022
  • 8
  • 15