cychia 0 Posted December 12, 2019 I have a thttpcli which will be used for sending http postasync to my server, I found out that sometimes I will get the request done event with StatusCode as 0 and reasonphrase is empty and errocode is 0 Initially I was thinking it is my server problem, but then I found out that, in httpprot, it will perform a postmessage for triggering request done event, but before postmessage, the state already changed to httpready, which means the socket is ready for another eequest. In my code, the socket is reuse, with every request, I will be checking the state if it is not ready, i will be adding my request to queue. If it is ready, request will be sent, once new request started, StatusCode, reasonphrase value will be reinit to 0 and empty, then only I received the onrequestdone event which previously was postmessage to wind message queue, at this moment the statuscode is no longer 200 as it was reinit Is this known issue? Any workaround? Thanks. Share this post Link to post
Angus Robertson 574 Posted December 12, 2019 Not looked at the code, but generally status=0 means an internal error or something unrelated to the HTTP protocol like SSL or disk I/O, hopefully your application logs all the protocol commands and responses which will help indicate at what point the error happened. If you use TSslHttpRest instead of THttpCli, logging is built-in. I would not rely on the component internal state completely, you should not start a new request until after OnRequestDone has been called, ie post a message from that event that triggers the next request in the queue, Angus Share this post Link to post
cychia 0 Posted December 12, 2019 (edited) 3 hours ago, Angus Robertson said: Not looked at the code, but generally status=0 means an internal error or something unrelated to the HTTP protocol like SSL or disk I/O, hopefully your application logs all the protocol commands and responses which will help indicate at what point the error happened. If you use TSslHttpRest instead of THttpCli, logging is built-in. I would not rely on the component internal state completely, you should not start a new request until after OnRequestDone has been called, ie post a message from that event that triggers the next request in the queue, Angus i have attached the log from ICSLogger, the highlighted RequestDone for both were different. First one is normal which i get StatusCode 200, second one was the problem i have encountered, StatusCode 0. The second requestdone was found after dnslookup, but from my socket sniffer, server return StatusCode 200 OK Edited December 12, 2019 by cychia Share this post Link to post
Angus Robertson 574 Posted December 12, 2019 The ICSLogger is designed for our internal debugging of the components, and needs extra information added to be useful for application level debugging, such as when you start a request, and the events called. It does not log the NTLM requests,. which is where your statuscode is coming from, not the real request. Beware we don't often test NTLM since it so rarely used on the public internet. Angus Share this post Link to post
cychia 0 Posted December 12, 2019 8 hours ago, Angus Robertson said: Not looked at the code, but generally status=0 means an internal error or something unrelated to the HTTP protocol like SSL or disk I/O, hopefully your application logs all the protocol commands and responses which will help indicate at what point the error happened. If you use TSslHttpRest instead of THttpCli, logging is built-in. I would not rely on the component internal state completely, you should not start a new request until after OnRequestDone has been called, ie post a message from that event that triggers the next request in the queue, Angus The thing that I find it strange is, in httpprot, when response received from server, it will set the state to ready, then postmessage to it's wndproc, this will.make way for second request to kick in, and reset the statuscode, reasonphrase etc, before request done event triggered. This means that the state for checking socket readiness is not reliable. Why not change postmessage to send message, or set state to ready only request done event is triggered? Is it safe if I move the part that change state to ready after request done is triggered? Share this post Link to post
Angus Robertson 574 Posted December 12, 2019 If you use the component in the recommended way as I said earlier, it works fine, and does for many others. There are no plans to change the internals of THttpCli, unless necessary to fix some horrible issue, it's been fine for 20 years. Angus Share this post Link to post