views:

71

answers:

2

Hi,

I wrote a test WCF service that returns a string array as long as the parameter of the method.

public class XNS_Test : IXNS_Test {
 public string[] testString(int num) {
  string[] s = new string[num];
  for(int i = 0; i < num; i++) {
   s[i] = "abcde";
  }
  return s;
 }}

I wrote a Form App to see how much time it takes:

private void button1_Click(object sender, EventArgs e) {
  int num = Convert.ToInt32(textBox1.Text);
  int[] intArr;
  string[] stringArr;

  TimeSpan start = DateTime.Now.TimeOfDay;
  try {
   XNS_Test.XNS_TestClient client = new testWCFServices.XNS_Test.XNS_TestClient();
   if(((Button)sender).Name == "button2")
    intArr = client.testInt(num);
   else
    stringArr = client.testString(num);
  }
  catch { }
  TimeSpan stop = DateTime.Now.TimeOfDay;
  label1.Text += num.ToString() + " elements: " + stop.Subtract(start).ToString() + "\n";
 }

If I try to generate a string[x] where x<=2480 the service answer in less then 5 seconds, otherwise a timeout occurs (I set it to 1 minute).

Why a string[] of 2480 is returned in 4 seconds and a string[] of 2481 causes a timeout.

I think I have to change a config setting but I don't know which one.

I use wsHttpBinding with reliableSession and without security.

Thanks,

Alberto

A: 

It is possible you are just taking too much time to create 2481 strings on the heap, but unlikely or you are excedding some maxsize limitation etc. However this is my guess. The best way for you to troubleshoot a WCF service issue is to enable tracing and then examining the trace using svctraceviewer tool. The logs are very detailed and should pinpoint the issue.

http://msdn.microsoft.com/en-us/library/ms733025.aspx

Pratik
+1  A: 

The maximum transfer size is quite low by default, 64K from memory. You can adjust a parameter on the connection called maxReceivedMessageSize in the config file.

JimG
YESSSSSS!PERFECT!THANKS THANKS THANKS!I was going crazy! You saved me! THANKS!
Alberto