POST request

128 views
Skip to first unread message

JLM

unread,
Apr 19, 2011, 11:10:21 AM4/19/11
to MochiWeb
Hi,
I am trying to simply use the function Data = Req:parse_post(), in my
app but the server never respond until 300 seconds.
It seems that it's waiting for something.
My HTTP Client is a firefox add-on called "REST Client" on which I've
configured a POST request with a request Boyd to an URL served by my
mochiweb application (GET requests work fine).

Mochiweb version : retrieved from master branch on github on the
04/14/2011

Bob Ippolito

unread,
Apr 19, 2011, 12:07:26 PM4/19/11
to moch...@googlegroups.com
Are you sure the client is sending a POST request, with data?

> --
> You received this message because you are subscribed to the Google Groups "MochiWeb" group.
> To post to this group, send email to moch...@googlegroups.com.
> To unsubscribe from this group, send email to mochiweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/mochiweb?hl=en.
>
>

Julien

unread,
Apr 19, 2011, 12:57:01 PM4/19/11
to moch...@googlegroups.com, moch...@googlegroups.com
I've done the same test with a wget command with the option --post-data combined with datas '<json struct>'. Note : wget will automatically provide a Content-Length header.
Got the same behavior, the request stays hanged in the recv method of mochiweb_request


((((((( JLM ))))))))

Bob Ippolito

unread,
Apr 19, 2011, 1:34:18 PM4/19/11
to moch...@googlegroups.com
What exactly is the code you're using? Which platform are you running it on?

Julien

unread,
Apr 19, 2011, 2:47:55 PM4/19/11
to moch...@googlegroups.com, moch...@googlegroups.com
I use a simple code with a case on GET or POST Methods. I'll attach my code asap.
My platform is Linux Ubuntu 10.04 and OTP R14B02.


((((((( JLM ))))))))

JLM

unread,
Apr 20, 2011, 10:20:36 AM4/20/11
to MochiWeb
Sorry. Absolutely not Mochiweb's fault or of my platform.
I've started a blank application with mochiweb and POST requests work
just fine.

In fact, my application is based on the articles by Richard Jones
about a 1-Million user comet application.
In one of the comments, someone provided a way to detect for client
disconnections by adding the following lines at the beginning of the
loop function :
Socket = Req:get(socket),
inet:setopts(Socket, [{active, once}]),

And this is what spoiled the behavior of POST requests.
Maybe is there a better way to manage client disconnections on long
running requests ?


On Apr 19, 7:34 pm, Bob Ippolito <b...@redivi.com> wrote:
> What exactly is the code you're using? Which platform are you running it on?
>
>
>
>
>
>
>
> On Tue, Apr 19, 2011 at 9:57 AM, Julien <jlama...@gmail.com> wrote:
> > I've done the same test with a wget command with the option --post-data combined with datas '<json struct>'. Note : wget will automatically provide a Content-Length header.
> > Got the same behavior, the request stays hanged in the recv method of mochiweb_request
>
> > ((((((( JLM ))))))))
>
> > On 19 avr. 2011, at 18:07, Bob Ippolito <b...@redivi.com> wrote:
>
> >> Are you sure the client is sending a POST request, with data?
>
> >> On Tue, Apr 19, 2011 at 8:10 AM, JLM <jlama...@gmail.com> wrote:
> >>> Hi,
> >>> I am trying to simply use the function Data = Req:parse_post(), in my
> >>> app but the server never respond until 300 seconds.
> >>> It seems that it's waiting for something.
> >>> My HTTP Client is a firefox add-on called "REST Client" on which I've
> >>> configured a POST request with a request Boyd to an URL served by my
> >>> mochiweb application (GET requests work fine).
>
> >>> Mochiweb version : retrieved from master branch on github on the
> >>> 04/14/2011
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups "MochiWeb" group.
> >>> To post to this group, send email to moch...@googlegroups.com.
> >>> To unsubscribe from this group, send email to mochiweb+u...@googlegroups.com.
> >>> For more options, visit this group athttp://groups.google.com/group/mochiweb?hl=en.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups "MochiWeb" group.
> >> To post to this group, send email to moch...@googlegroups.com.
> >> To unsubscribe from this group, send email to mochiweb+u...@googlegroups.com.
> >> For more options, visit this group athttp://groups.google.com/group/mochiweb?hl=en.

Bob Ippolito

unread,
Apr 20, 2011, 10:33:25 AM4/20/11
to moch...@googlegroups.com
Yes, doing anything to the socket before parsing the request is a very
quick way to fail.

Detecting disconnections is not really necessary, the process will
terminate when that happens... but only while you're waiting on
activity from the socket, such as parsing the request body or waiting
for the next request. Richard's method should only be useful if you're
long-polling and you want to detect a disconnect from the client
before you send the response.

On Wed, Apr 20, 2011 at 12:37 AM, JLM <jlam...@gmail.com> wrote:
> Sorry and thanks for quick answers.
>
> I've found my mistake by starting from a new sample app and it works
> perfectly. It's absolutely not Mochiweb's fault.
>
> I've used a sample code on an article by Richard Jones about a one-
> million users Comet Application.
> In comments, someone provided a way to detect for disconnections by
> configuring Socket :


> Socket = Req:get(socket),
> inet:setopts(Socket, [{active, once}]),
>

> This is the reason why POST requests never ended.
> So I've moved this code in the GET request case I used for the Comet
> behavior.
> Maybe would you have a better way to detect when a client
> disconnects ?


>
>
> On Apr 19, 7:34 pm, Bob Ippolito <b...@redivi.com> wrote:

>> What exactly is the code you're using? Which platform are you running it on?
>>
>>
>>
>>
>>
>>
>>
>> On Tue, Apr 19, 2011 at 9:57 AM, Julien <jlama...@gmail.com> wrote:
>> > I've done the same test with a wget command with the option --post-data combined with datas '<json struct>'. Note : wget will automatically provide a Content-Length header.
>> > Got the same behavior, the request stays hanged in the recv method of mochiweb_request
>>
>> > ((((((( JLM ))))))))
>>
>> > On 19 avr. 2011, at 18:07, Bob Ippolito <b...@redivi.com> wrote:
>>
>> >> Are you sure the client is sending a POST request, with data?
>>

>> >> On Tue, Apr 19, 2011 at 8:10 AM, JLM <jlama...@gmail.com> wrote:
>> >>> Hi,
>> >>> I am trying to simply use the function Data = Req:parse_post(), in my
>> >>> app but the server never respond until 300 seconds.
>> >>> It seems that it's waiting for something.
>> >>> My HTTP Client is a firefox add-on called "REST Client" on which I've
>> >>> configured a POST request with a request Boyd to an URL served by my
>> >>> mochiweb application (GET requests work fine).
>>
>> >>> Mochiweb version : retrieved from master branch on github on the
>> >>> 04/14/2011
>>
>> >>> --
>> >>> You received this message because you are subscribed to the Google Groups "MochiWeb" group.
>> >>> To post to this group, send email to moch...@googlegroups.com.
>> >>> To unsubscribe from this group, send email to mochiweb+u...@googlegroups.com.

>> >>> For more options, visit this group athttp://groups.google.com/group/mochiweb?hl=en.


>>
>> >> --
>> >> You received this message because you are subscribed to the Google Groups "MochiWeb" group.
>> >> To post to this group, send email to moch...@googlegroups.com.
>> >> To unsubscribe from this group, send email to mochiweb+u...@googlegroups.com.

>> >> For more options, visit this group athttp://groups.google.com/group/mochiweb?hl=en.


>>
>> > --
>> > You received this message because you are subscribed to the Google Groups "MochiWeb" group.
>> > To post to this group, send email to moch...@googlegroups.com.
>> > To unsubscribe from this group, send email to mochiweb+u...@googlegroups.com.

>> > For more options, visit this group athttp://groups.google.com/group/mochiweb?hl=en.

JLM

unread,
Apr 20, 2011, 3:37:32 AM4/20/11
to MochiWeb
Sorry and thanks for quick answers.

I've found my mistake by starting from a new sample app and it works
perfectly. It's absolutely not Mochiweb's fault.

I've used a sample code on an article by Richard Jones about a one-
million users Comet Application.
In comments, someone provided a way to detect for disconnections by
configuring Socket :
Socket = Req:get(socket),
inet:setopts(Socket, [{active, once}]),

This is the reason why POST requests never ended.
So I've moved this code in the GET request case I used for the Comet
behavior.
Maybe would you have a better way to detect when a client
disconnects ?


On Apr 19, 7:34 pm, Bob Ippolito <b...@redivi.com> wrote:
> What exactly is the code you're using? Which platform are you running it on?
>
>
>
>
>
>
>
> On Tue, Apr 19, 2011 at 9:57 AM, Julien <jlama...@gmail.com> wrote:
> > I've done the same test with a wget command with the option --post-data combined with datas '<json struct>'. Note : wget will automatically provide a Content-Length header.
> > Got the same behavior, the request stays hanged in the recv method of mochiweb_request
>
> > ((((((( JLM ))))))))
>
> > On 19 avr. 2011, at 18:07, Bob Ippolito <b...@redivi.com> wrote:
>
> >> Are you sure the client is sending a POST request, with data?
>
> >> On Tue, Apr 19, 2011 at 8:10 AM, JLM <jlama...@gmail.com> wrote:
> >>> Hi,
> >>> I am trying to simply use the function Data = Req:parse_post(), in my
> >>> app but the server never respond until 300 seconds.
> >>> It seems that it's waiting for something.
> >>> My HTTP Client is a firefox add-on called "REST Client" on which I've
> >>> configured a POST request with a request Boyd to an URL served by my
> >>> mochiweb application (GET requests work fine).
>
> >>> Mochiweb version : retrieved from master branch on github on the
> >>> 04/14/2011
>
> >>> --
> >>> You received this message because you are subscribed to the Google Groups "MochiWeb" group.
> >>> To post to this group, send email to moch...@googlegroups.com.
> >>> To unsubscribe from this group, send email to mochiweb+u...@googlegroups.com.
> >>> For more options, visit this group athttp://groups.google.com/group/mochiweb?hl=en.
>
> >> --
> >> You received this message because you are subscribed to the Google Groups "MochiWeb" group.
> >> To post to this group, send email to moch...@googlegroups.com.
> >> To unsubscribe from this group, send email to mochiweb+u...@googlegroups.com.
> >> For more options, visit this group athttp://groups.google.com/group/mochiweb?hl=en.
Reply all
Reply to author
Forward
0 new messages