[Mono-list] HttpWebRequest concurrency issues

Ian Norton ian.norton-badrul at thales-esecurity.com
Tue Dec 18 08:38:32 UTC 2012


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 17/12/12 21:16, Esben Laursen wrote:
> I have seen a problem where mono would close a connection after the
> http request/response was done, it didnt break anything it just
> initiated a new session on every request even though it should use
> the same (it works on Windows). I have just recently upgraded on of
> my "test" machines to 3.0.1 (running CentOS, compiled from
> source)..
> 
> As far as I can tell, its the same problem on 2.6.x and 3.0.1. So
> if you find otherwise please speak up, as I would be really
> interested...
> 
> Now this being said, I have not yet done much work in this area of
> the code, the reason I upgraded was I was hitting a memory leak in
> the 2.6.x code (as far as I can tell)..
> 
> I usually have 10 threads that do HTTP POST to send some text back
> to a server. I would like for it to use the same session again and
> again (or 10 sessions) in this case, but it closes after every POST
> (or GET for that matter)
> 

It just goes to show that I should read these emails more before
replying to them.

I'm using my pmono build ( mono 3.0 ) and see the same things.
Basically, every WebRequest object with the same server address I
create ( and also dispose ) will subsequently re-use the same TCP
socket to my webserver.  I'm all for re-using existing HTTP
connections but this seems very odd behavior especially given I
dispose the object.

This is easy to reproduce (I'm actually seeing it underneath the
JayRock JSON RPC client which extends WebRequest).

So.. what I see is:-

..that web requests using separate objects one after another always
re-use the HTTP conneciton unless the server has closed the socket.

..often any request made in parallel to the same address fails with a
timeout.

Ian
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iQEcBAEBAgAGBQJQ0CuIAAoJEPg9tunm1IFQbx4H/2UFKW3Tn/3JVjUOY8d5KFBd
Zy3oNHlHH0OHPhharRTIB4J93QLGILMVZG2q+mX3rGCqS6+YnccRBf6tsQySVjPS
6xQ+8zJkWVJGWJ/dC44Fh+hR68jj6hnZ5rMDRZDauGFv6zrf3aOeyWxDJiFgvezD
cHfcvj1PAbdMmJ9kH1C0zVq5LPSfnvH4GnK+ysMkkCT3tI4/TqUWmHj/+ZrYzVQz
YGb86pFpAuJ3TUl8wCuj1FLL4lA/s8PStpsd2liCLF2TaDQtmqdAFk7UQF2U9pPD
hD4vNa4fTNvrDeTVD3vRr3a3vBLGmFjNU603RdlLF0J8Dwa6EtnzikuaOBA4GH0=
=jsjC
-----END PGP SIGNATURE-----


More information about the Mono-list mailing list