libmicrohttpd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [libmicrohttpd] Hanging connections


From: Kenneth Mastro
Subject: Re: [libmicrohttpd] Hanging connections
Date: Tue, 3 Nov 2015 10:15:48 -0500

Somebody with more knowledge may want to chime in, but I have a few random thoughts...

1) If you're using 'thread per connection' and your callback just isn't getting called AT ALL... Is it possible that you only have 1 thread allotted and it's already being consumed by another request?  I.e., what does your call to 'MHD_start_daemon' look like?  Do you have a connection limit set?  What about a connection timeout?  (If you have a connection timeout, try reducing it to something really short - see if the symptoms improve.)

2) On the browser side, use something like Firebug (for Firefox) or Chrome's built-in tools and see what it thinks is happening to the connections/requests.

3) Try make sure all your 'GET' requests are working properly before diving into 'POST' (which tends to be much harder - at least it was for me).

4) That connection callback is a little funky because it gets called twice for every request.  I'm assuming you're handling that, but just keep that in mind.

5) Finally - I think the 0.9.45 release had something in it that fixed a minor bug with thread-per-connection.  I haven't tried updating to it yet (I'm a version or 2 behind right now), but if you're pretty sure your code is correct you could always try rolling back to an earlier version - see if a regression of some kind was introduced.  (Unlikely, but 0.9.45 hasn't been out very long so you never know.)


As a side note - MHD is a really great library.  It can be a little challenging to get your 'web server' working initially, but I've found that it performs really well and is very reliable once you do.


Ken



On Mon, Nov 2, 2015 at 8:18 PM, Phil Rosenberg <address@hidden> wrote:
Hi
I have just started using microhttpd to provide web access to control
some software I have written. However I've just hit a problem. I'm not
a http expert, so please bear with me.

I have set up MHD to respond to get and post requests. For both cases
I return a html form to the client with some text boxes and a submit
button. The form is followed by the time, so I can check that the page
has updated. For a post request I parse the keys to extract the
information I need to control my application. I'm using one thread per
connection. My code was initially based on the minimal example on the
web page, I then added the POST processing code following the
tutorial.

I am using version 0.9.45 built on Windows 10 using Visual Studio 2015
Community Edition.

Unfortunately about 50% of the time when I press the submit button in
the browser I get a loading symbol in the tab, but nothing happens.
Pressing the submit button again usually seems to get things working,
but sometimes it takes quite a few button presses.

Running in the debugger I can see that for these hung connections my
first callback is not being called. I think the port is still open or
something, because exiting my application causes the browser to
immediately display a cannot connect message. It's like MHD is stuck
in a loop internally or something.

I've tried connecting with IE and Edge from the local machine and from
Firefox from an Ubuntu machine on the same LAN. All give similar
symptoms.

One possibly relevant item - I get similar hangs if I reply MHD_NO to
any of the callbacks, which I thought was supposed to sever the
connection.

As I said I'm not an expert on HTTP, and I've only just picked up MHD,
so any debugging advice would be most welcome. I'm happy to do the
legwork, but I'm struggling to know where to start.

Thanks in advance for any help

Phil



reply via email to

[Prev in Thread] Current Thread [Next in Thread]