You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am using you library, it works great when i get status code: 200.
But if the server send error for some reason, then i get status code -2 or -3 and then it is not send again requests to server.
We have run into the same issue. From what I can tell reading the library's code, this is what is happening:
We try reading the response status code with responseStatusCode().
For some reason, this reaches timeout (-3). Not sure why this is happening in our case, but I assume it could be attributed to an unstable internet connection? (If anyone knows more about this, please let me know)
The state of the library is now at "reading status code". Because of this, post() returns the error specifying that it has been called in an unexpected state (-2). This is because in startRequest, the state is reset in some cases (if (iState == eReadingBody || iState == eReadingChunkLength || iState == eReadingBodyChunk)), but since iState is eReadingStatusCode, it is not reset, resulting in an early return with -2.
Is there a good reason as to why the state is only reset in those three cases? Might simply adding an || iState == eReadingStatusCode solve the problem, or will that have other unexpected side effects? (Or am I wrong in my reconstruction altogether?)
@roysG did you perhaps find another way to solve or work around the issue?
We did find a very simple workaround: simply construct new HttpClient objects before each post rather than keeping a global HttpClient object.
I actually think that this is generally more sensible: HTTP is stateless, so keeping a global (stateful) HttpClient object is error-prone and logically inconsistent. It might be better practice to create the object on-the-fly and keep them only for as long as the code depends on that request and its result.
Hi,
I am using you library, it works great when i get status code: 200.
But if the server send error for some reason, then i get status code -2 or -3 and then it is not send again requests to server.
Code:
The text was updated successfully, but these errors were encountered: