Bug 25698 - WCF REST service hangs for PUT requests
Summary: WCF REST service hangs for PUT requests
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: WCF assemblies (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2015-01-04 02:20 UTC by SJ
Modified: 2017-09-06 16:55 UTC (History)
5 users (show)

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


Attachments
minimal sample to reproduce problem (1.41 KB, text/plain)
2015-06-25 17:33 UTC, Tom
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report for Bug 25698 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
NEW

Description SJ 2015-01-04 02:20:58 UTC
WCF REST service has been decorated with the Put method. When sending a request, it hangs where the service doesn't even see the request come through

[WebInvoke(UriTemplate = "Add", Method = WebRequestMethods.Http.Put, RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json,
            BodyStyle = WebMessageBodyStyle.Wrapped)]
        public int Add(int i)
        {
            Console.WriteLine("Inside Add");
            count++;
            return i + count;
        }


PUT http://XXXX/Add HTTP/1.1
Accept: application/json
Content-Type: application/json
Connection: Keep-Alive
Pragma: no-cache
Content-Length: 6

121111

Interestingly the same method is processed when I change the client uses POST as the METHOD Type.

-----------Request--------------
POST http://XXXX/Add HTTP/1.1
Accept: application/json
Content-Type: application/json
Connection: Keep-Alive
Pragma: no-cache
Content-Length: 6

121111

-----------Response--------------
HTTP/1.1 200
Content-Type: application/xml; charset=utf-8
Server: Mono-HTTPAPI/1.0
Date: Sun, 04 Jan 2015 07:17:00 GMT
Content-Length: 77
Keep-Alive: timeout=15,max=100

<int xmlns="http://schemas.microsoft.com/2003/10/Serialization/">121112</int>
Comment 1 Tom 2015-06-25 15:35:50 UTC
Experiencing the same results, for any verb except GET or POST. PUT, DELETE, OPTIONS, and custom verbs (tested via curl -X) all result in a hung thread and no-response.

Mono version is build from tarball 4.0.2 (.5/c99aa0c), also can reproduce with 3.2.8 (also from tarball).

I'm doing trivial self-hosting using WCF REST, webHttpBinding, <webHttp />, ServiceHost(). My method looks like:

[WebInvoke(Method="DELETE",
           UriTemplate="api/in/http/{id}",
           BodyStyle=WebMessageBodyStyle.Bare,
           RequestFormat=WebMessageFormat.Json,
           ResponseFormat=WebMessageFormat.Json)]

But this seems irrelevant, because no matter which URI I request, if it is within the web app root and uses a verb other than GET or POST, it hangs.
Comment 2 Tom 2015-06-25 16:39:26 UTC
(Argh, waited too long and can't update my previous comment!)

Tracing the Chanels.Http namespace, it looks like the HttpChannelListener accepts the connection, calls TryDequeueRequest and... just stays there? Because the tracing stops there unless I kill the app.

[0x7fe88698c700: 8.81124 0] LEAVE: System.ServiceModel.Channels.Http.HttpChannelListener`1:OnAcceptChannel (System.TimeSpan)(unknown return type 13)
[0x7fe88698c700: 8.81213 0] ENTER: System.ServiceModel.Channels.Http.HttpReplyChannel:OnOpen (System.TimeSpan)(this:0x7fe8970ec9b8[System.ServiceModel.Channels.Http.HttpReplyChannel dcfdistributionserver.exe], [], )
[0x7fe88698c700: 8.81222 0] LEAVE: System.ServiceModel.Channels.Http.HttpReplyChannel:OnOpen (System.TimeSpan)
[0x7fe88698c700: 8.81234 0] ENTER: System.ServiceModel.Channels.Http.HttpReplyChannel:TryReceiveRequest (System.TimeSpan,System.ServiceModel.Channels.RequestContext&)(this:0x7fe8970ec9b8[System.ServiceModel.Channels.Http.HttpReplyChannel dcfdistributionserver.exe], [], [BYREF:0x7fe8970ed070], )
[0x7fe88698c700: 8.81237 1] ENTER: System.ServiceModel.Channels.Http.HttpListenerManager:TryDequeueRequest (System.ServiceModel.Dispatcher.ChannelDispatcher,System.TimeSpan,System.ServiceModel.Channels.Http.HttpContextInfo&)(this:0x7fe8970e0878[System.ServiceModel.Channels.Http.HttpStandaloneListenerManager dcfdistributionserver.exe], [System.ServiceModel.Dispatcher.ChannelDispatcher:0x7fe89706d0f8], [], [BYREF:0x7fe88698b700], )

And this is the last we hear from thread 8c700.
Comment 3 Tom 2015-06-25 17:33:42 UTC
Created attachment 11742 [details]
minimal sample to reproduce problem

dmcs -r:System.ServiceModel -r:System.ServiceModel.Web hangdemo.cs -out:hangdemo.exe

mono hangdemo.exe <-- in another window

curl http://localhost:8083/ep/item/bar

>> Prints "bar"

curl DELETE http://localhost:8083/ep/item/bar <-- or any url 

>> hangs forever
Comment 4 Ernestas 2016-03-04 08:29:39 UTC
I have the same problem on 

Mono JIT compiler version 4.2.1
Raspbian GNU/Linux 8 \n \l

I can confirm that the request didn't reach Custom MessageEncoder, ReadMessage method, and response is only returned after the service is killed. Only GET, POST Methods work.
Comment 5 jcde 2016-08-02 15:29:05 UTC
The fix should be in HttpReplyChannel.cs

if (ctxi.Request.HttpMethod == "POST" || ctxi.Request.HttpMethod == "PUT" )
    msg = CreatePostMessage (ctxi);
else if (ctxi.Request.HttpMethod == "GET" || ctxi.Request.HttpMethod == "DELETE" || ctxi.Request.HttpMethod == "OPTIONS")
    msg = Message.CreateMessage (MessageVersion.None, null);

http://stackoverflow.com/questions/35769843/mono-service-wcf-options-on-rasbian