Bug 13880 - self-hosted webapi application stops responding after first requests
Summary: self-hosted webapi application stops responding after first requests
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web (show other bugs)
Version: unspecified
Hardware: Other Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-08-09 06:00 UTC by Tomas Gustavsson
Modified: 2016-11-08 17:40 UTC (History)
8 users (show)

See Also:
Is this bug a regression?: ---
Last known good build:

Self hosted web api application (3.54 MB, application/x-zip-compressed)
2013-08-09 06:00 UTC, Tomas Gustavsson

Description Tomas Gustavsson 2013-08-09 06:00:19 UTC
Created attachment 4594 [details]
Self hosted web api application

I created a simple WebAPI application (took code from http://www.piotrwalat.net/running-asp-net-web-api-services-under-linux-and-os-x/). Everything works just perfectly the problem comes when I try to make the application self hosted, for this I used HttpSelfHostServer.

On the first session of requests I get an answer from my application but any following requests are just ignored (and times out I believe). I can't see any high cpu/memory usage, it just seems to wait for something. The only solution for me is to restart the application, but restarting the application after each request isn't viable in the long run...

Also my version of Mono could be interesting I guess:
Mono 3.2.0
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
LLVM: supported, not enabled.
GC: sgen

Any help is much appreciated, thank you :).
Comment 1 Konstantin Burlachenko 2014-01-24 17:18:52 UTC
I can't give you help. But I have identical problem with Mono 3.2.3 on Windows, and with Mono 3.2.5 on Debian. x86_64 platforms.

SelfHosting aftet first GET request via http seems to rich deadlock.

Also I have open mono.exe in VS2012 to watch what about threads(real threads, not managed) - they wait for something.

Maybe in mono 3.2.6 it was been fixed....

Any comments, may be there is exist some stable TaskScheduler?
Comment 2 Marcin Żochowski 2014-02-28 15:14:21 UTC
I have reached exactly the same behavior on Mono 3.2.8, amd64, Ubuntu 13.10.
Comment 3 hailing22 2014-04-03 10:32:54 UTC
The exakt same problem for me on Mac OS X / Xamarin Studio 4.3.4 / Mono 3.4.0 (I switched to the Alpha Channel because Mono 3.4.0 seems to include changes in the network stack, but that did not solve the issue).

Browser only gets a response for the first request, all additional requests keep pending and don't complete. CPU does not show anything, in Xamarin no threads are active and no events seem to be called after the first successful request.

This is a Xamarin blocker for me as I want to port a .Net web api application that required self hosting.
Comment 4 gkirbo 2014-04-09 18:36:04 UTC
We need this too and I'm sad to see a major bug like this lingering for 8 months. I would be happy to sponsor a patch if someone wants to work on it.
Comment 5 Nick 2016-10-26 13:21:57 UTC
I came across this issue while using Mono 3.2.8 that comes with Debian Jessie. It seems to be a version mismatch/incompatibility so you have a few options:
* Update to a newer version of mono
* Use the Debian provided assembly (/usr/lib/mono/gac/System.Web.Http.SelfHost/ from https://packages.debian.org/stable/cli-mono/libmono-system-web-http-selfhost4.0-cil although this does not seem to work on Windows.
* Build a custom version of System.Web.Http.SelfHost against the updated dependencies which will work in both Windows and Linux based on https://github.com/mono/mono/tree/mono-3.2.8-branch or more specifically https://github.com/mono/aspnetwebstack/commits/e77b12e6cc5ed260a98447f609e887337e44e299 which is referenced by mono-3.2.8-branch.

I hope that helps anybody who still comes across this issue.
Comment 6 Konstantin Burlachenko 2016-11-08 17:40:59 UTC
@Nick, thanks for answer. But instead it I think my solution will be in the following - I will never use Mono and/or C# at all from this point of my life!

Note You need to log in before you can comment on or make changes to this bug.