On Wed, 26 Jun 2013 15:40:08 GMT, Sönke Ludwig wrote:
Am 26.06.2013 16:31, schrieb Colin Grogan:> On Wed, 26 Jun 2013 13:52:42 GMT, Sönke Ludwig wrote:
Am 26.06.2013 13:58, schrieb Colin Grogan:> Hi,
Im getting this error on the second request being sent by a single HTTPClient.
My code is as follows:
HTTPClient client = connectHTTP(server, "80", false); auto res1 = client.request( (scope req){ req.method=HTTPMethod.POST; req.requestURL = "loginform?username="~name~"&password=passw0rd"; } ); (...)
The issue caused by not reading the response body of
res1
before using the same HTTP connection to make the second request. A call tores1.dropBody()
should fix that. I would, however, recommend to use the other overload ofrequest
, which takes two callbacks instead of cone. It automatically drops the body if it wasn't fully read before returning.You can also simplify the code by using
requestHTTP
instead of manually creating aHTTPClient
. That will also avoid such interleaved requests by returning a new connection if all existing ones are still in use.Excellent, that works, thanks.
I expect to be issuing thousands of requests quite quickly, so I didnt want to overload my server with connections. Thats why I decided to go with creating aHTTClient
object and using that instead ofrequestHTTP()
requestHTTP
uses the same connection pool asconnectHTTP
and will reuse existing connections whenever possible, so this should not be an issue.While your there, how do I cleanly shutdown Vibe's event loop?
CallingstopEventLoop()
throws lots of errors and typing <Ctrl>+c feels unclean to me.
I'm guessing creating my own main function would be the way to go about it, but said I'd ask in case there was something I was missing?
Been reading through the docs pretty heavily in the last while looking for something but haven't come across anything obvious.There is still an unresolved issue that causes the event loop to keep running, even if all event handlers have been destroyed. Once that is resolved, the appliction will exit automatically once all tasks have exited and all listeners have been stopped. However,
exitEventLoop
is supposed to work, too. What errors does it throw exactly?BTW, Ctrl+C is actually also triggering an
exitEventLoop
call, so it will usually be a more-or-less clean shutdown.
It seems pretty sporadic, but the exception is an InvalidMemoryOperation.
I've been trying to get it to occur so I could get the exception details but it isn't happening today :)