Results 1 to 4 of 4

Thread: Server rejects client requests

  1. #1
    Join Date
    Jan 2009
    Location
    United States
    Posts
    6

    Unhappy Server rejects client requests

    Background:
    I have a small PC104 running opensuse 11.1. I'm writing a small client/server application for debugging purposes using mono and WCF. All the client does is make a request for information every 100ms.

    Problem:
    After about 20 requests the server quits responding to the client. Even if the client is running on the same machine. I've run the exact code on another laptop running opensuse as well as a laptop running windows and everything works great. Hopefully that closes the option that it is a code, mono, or opensuse flaw.

    Is there a kernel option or a network option that anyone knows about that might cause this sort of behavior?

    Thanks!

    Jeremy

  2. #2
    Join Date
    Dec 2009
    Location
    Thailand
    Posts
    60

    Default Re: Server rejects client requests

    Your client requests to server from web browser or not?

    In case i think about mono code. You can check log file from /var/log/message
    Regards,
    SuSEThailand.com is a SUSE Linux user and community found in Thailand.

  3. #3
    Join Date
    Jan 2009
    Location
    United States
    Posts
    6

    Default Re: Server rejects client requests

    I've upgraded my small PC104 to openSUSE 11.3. The performance is much better. However, now it will die after several hundred or sometimes even thousand iterations. I've also discovered that on my laptop it dies after a while too. Also, it seems that for some reason the app is limited to about 10 operations per second. When running this exact code on my windows machine I can get 600+ operations per second (in fact, it's running right now and on iteration 210,000). Any ideas?

    Mono JIT compiler version 2.6.4 (tarball Mon Jul 5 13:23:55 UTC 2010)
    MonoDevelop 2.4

    Here is the code:

    Code:
    // Server --> Add reference to System.ServiceModel
    using System;
    using System.IO;
    using System.ServiceModel;
    using System.ServiceModel.Channels;
    
    namespace WCFTest2
    {
    	[ServiceContract(Namespace="http://work.com")]
    	public interface IHelloService
    	{
    		[OperationContract]
    		 string Greeting(string name);
    	}
    	
    	public class HelloService : IHelloService
    	{		
    		public string Greeting(string name)
    		{
    			Console.WriteLine("Got a request: " + DateTime.Now.ToString());
    			return name + " is a great name.";
    		}
    	}
    	
    	class MainClass
    	{		
    		public static void Main (string[] args)
    		{
    			string connection = "http://localhost:8080";
    
    			Console.WriteLine ("Hello World! I'm the server!");
    			Binding binding = new BasicHttpBinding();
    			var address = new Uri(connection);
    			ServiceHost host = new ServiceHost(typeof(HelloService));
    			host.AddServiceEndpoint(typeof(IHelloService), binding, address);
    			host.Open();
    			Console.WriteLine("I'm running...");
    			while(true)
    			{
    				Console.Write(".");
    				if(Console.CursorLeft >= 60) Console.WriteLine("<-- ~1 min");
    				System.Threading.Thread.Sleep(1000);
    			}
    		}
    	}
    }
    Code:
    // Client --> Add reference to System.ServiceModel
    using System;
    using System.ServiceModel;
    using System.ServiceModel.Channels;
    
    namespace WCFClient
    {
    	[ServiceContract(Namespace="http://work.com")]
    	public interface IHelloService
    	{
    		[OperationContract]
    		string Greeting(string name);
    	}
    	
    	public class HelloClient : ClientBase<IHelloService>, IHelloService
    	{
    		public HelloClient(Binding b, EndpointAddress a) : base (b, a)
    		{
    			// empty
    		}
    		
    		public string Greeting(string name)
    		{
    			return Channel.Greeting(name);
    		}
    	}
    	
    	class MainClass
    	{
    		static int numTransactions = 0;
    		static DateTime startTime;
    		
    		public static void Main (string[] args)
    		{			
    			Console.WriteLine ("Hello World! I'm the client!");
    			Console.WriteLine("Waiting 3 seconds for the server to start up...");
    			for(int i = 0; i < 3; i++)
    			{
    				System.Threading.Thread.Sleep(1000);
    				Console.Write(".");
    			}
    			Console.WriteLine();
    
    			string connection = "http://localhost:8080";
    
    			var binding = new BasicHttpBinding();
    			var address = new EndpointAddress(connection);
    			var client = new HelloClient(binding, address);
    			
    			string name = "bob";
    			startTime = DateTime.Now;
    			while(true)
    			{
    				string time = DateTime.Now.ToString("HH:mm:ss");
    				try
    				{
    					Console.Write(time + " - ");
    					Console.WriteLine(numTransactions++ + "-" + client.Greeting(name));
    				}
    				catch(Exception ex)
    				{
    					Console.WriteLine("\t-->" + ex.Message + "@" + time);
    				}
    			}
    		}
    	}
    }

  4. #4
    Join Date
    Jun 2008
    Location
    San Diego, Ca, USA
    Posts
    11,405
    Blog Entries
    2

    Default Re: Server rejects client requests

    I suspect Garbage Collection.
    Like all managed code environments, GC performance is based on algorithms based on various assumptions, likely for expected Production use and not what you are doing which seems to be strictly an iteration exercise.

    You should be able to verify this by running a utility that monitors heaps (primarily) and general resources.

    If you find this is the case, it's possible to over-ride default the GC configuration but that'll take you into the Neverland of whether what you're doing remains educational and relevant to future projects.

    It's been awhile since I've worked with MonoDevelop (IIRC at the time I considered MonoDevelop I dropped it because it lacked a robust integrated debugger). If MonoDevelop still lacks good tracing, debugging and profiling you may have to instrument your code manually and/or run outside tools that can report real time resource info.

    HTH,
    Tony

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •