Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 18 | Comments: 78

filter by tags archive

Didja know, RavenDB include a proxy server

time to read 1 min | 124 words

This is one of those things that I had to read several times to realize what was actually going on.

The code for that is here: https://github.com/ayende/ravendb/blob/c0c9ccf98011fb64b5eb5406a900ec1338ea78e4/Raven.Tests/Issues/RavenDB_1603.cs#L32

And it appears that along with every else, RavenDB also include a proxy server.

Now, to be fair, this is required for our tests, to see what happens when we have a forced disconnect / timeout at the network level, so it make sense. And the whole thing is under 100 lines of code.

This sort of thing explains why we really need to do a whole bunch of work on our tests. We want to get to a 500 – 1000 tests (currently we have close to 3,200) that run in under 5 minutes.



Nice proxy, and some clever use of async I yet have to get used to. But for a beginning, what's the difference between

var read = await incomingStream.ReadAsync(buffer, 0, 4096, token);


var read = incomingStream.Read(buffer, 0, 4096)

is the first one any better?

Andy Pook

It looks like there are a couple of "bugs". Two of the while(true) loops look like will never exit (except on exception). In Forward it should probably use "!cancellationTokenSource.IsCancellationRequested" In the writeTask it should probably "break" when "read == 0" as the readTask does. An "extract method" refactoring would help.

Without these I think there's a task leak. Though as this is "just test code" it's safe enough :)

Ayende Rahien

Rafal, The first one is better because it will yield the thread for the duration of the actual IO, leaving it free to do other work.

Comment preview

Comments have been closed on this topic.


  1. Production postmortem: The industry at large - one day from now
  2. The insidious cost of allocations - about one day from now
  3. Buffer allocation strategies: A possible solution - 5 days from now
  4. Buffer allocation strategies: Explaining the solution - 6 days from now
  5. Buffer allocation strategies: Bad usage patterns - 7 days from now

And 2 more posts are pending...

There are posts all the way to Sep 11, 2015


  1. Find the bug (5):
    20 Apr 2011 - Why do I get a Null Reference Exception?
  2. Production postmortem (10):
    01 Sep 2015 - The case of the lying configuration file
  3. What is new in RavenDB 3.5 (7):
    12 Aug 2015 - Monitoring support
  4. Career planning (6):
    24 Jul 2015 - The immortal choices aren't
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats