Ayende @ Rahien

It's a girl

[Unstable code] So you think you are safe...

There is some interesting discussion on my previous post about unstable code.

I thought that it would be good to give a concrete example of the issue. Given the following interface & client code, is there a way to make this code block for a long time?

public interface IFoo
	string GetMessage();

var stopwatch = Stopwatch.StartNew();
var channel = ChannelFactory<IFoo>.CreateChannel(
	new BasicHttpBinding
		SendTimeout = TimeSpan.FromSeconds(1), 
		ReceiveTimeout = TimeSpan.FromSeconds(1),
		OpenTimeout = TimeSpan.FromSeconds(1),
                CloseTimeout = TimeSpan.FromSeconds(1)
	new EndpointAddress("http://localhost:6547/bar"));

var message = channel.GetMessage();

Console.WriteLine("Got message in {0}ms", stopwatch.ElapsedMilliseconds);

You are free to play around with the server implementation as well as the network topology.

Have fun....


Peter Ritchie
07/21/2008 05:24 PM by
Peter Ritchie

Lots of ways. Your timeout only applies to the binding; there's many other things that could take some time: the DNS lookup (some DNS implementations lookup "localhost"), the TCP listener on the server could do something funky and take some time, etc.

Tuna Toksoz
07/21/2008 05:37 PM by
Tuna Toksoz

The title reminded me [ThereBeDragonsAttribute] :)

Davy Landman
07/21/2008 06:09 PM by
Davy Landman

You could respond with a byte every 500ms for a very long time..

You could use a redirect loop :-)

Davy Landman
07/21/2008 06:12 PM by
Davy Landman

damn, reading your blog through an rss reader means I missed the fact that you allready posted the solution ;-)

Comments have been closed on this topic.