Skip to content

some very strange numbers from getLastReturnCode() #3

Description

@interactive-matter

Also, I seem to be getting some very strange numbers from getLastReturnCode(). The debugging prints show status 200, but getLastReturnCode is giving me varying numbers, even negative numbers:
1300
513
2
512
-236
1024
etc.. There seems to be no fixed pattern

Activity

  1. interactive-matter commented on Feb 10, 2013

    @interactive-matter
    OwnerAuthor

    this looks like a rather nasyt memory problem … will look into it (promised)

  2. bilics commented on Jun 3, 2013

    @bilics

    Hi there,

    I am facing the same problem here (Arduino Mega 2560).

    Any updates on this issue ?

    Thanks in advance,

  3. Apollon77 commented on Aug 13, 2015

    @Apollon77
    Contributor

    Same here, only in rare cases

  4. Apollon77 commented on Sep 3, 2015

    @Apollon77
    Contributor

    When I look at the code I don't know if the variable reference to the instance-variable is correct and the best way here:

    fscanf_P(stream, PSTR("HTTP/1.1 %i"), &lastReturnCode);

    maybe better to use a local variable to write it and copy that to the class member later on ?!

    I will change that locally and test it for some days.

  5. Apollon77 commented on Sep 10, 2015

    @Apollon77
    Contributor

    I discovered one thing: The code (especially with this fscanf) assumes that there is content to read. When there is no/not enough content to read then fscanf returns with EOF or 0 - return value of fscanf is normally the number of matched items (%i) or EOF on error.
    When we assume there is no data then I don't know (didn't find anything so far) what really happens to the variable that should be set with the value. Don't know if thepointer is used somehow and that's why there are stupid values in there?!
    I added some error-checking in my local code and will try it the next days.

  6. Apollon77 commented on Oct 1, 2015

    @Apollon77
    Contributor

    As an update: I've seen in my code that any time the fscanf_P was not able to match successfully the details are the same:

    • content available was "HTT"
    • ferror() returned "16" or the stream. feof() returned false
    • The read after it worked

    I will add debug output of "errno", but at least this is not set in HTTPClient class ... I will also try to make an available-loop till at least x characters are available before starting to read ... Will update here ...

  7. Apollon77 commented on Oct 6, 2015

    @Apollon77
    Contributor

    Next update:

    • errno does not have any value, so it brings not more infos.
    • I changed the code so that the first line is read in total and then the matching is done by sscanf ... so I have seen that it seems that mostly when the problem occurs only the irst 5 characters where read and the last was wrong ...

    After many tries I assumed a timing issue with receiving the data from remote ... so I tried to add a "delay(100)" to simply give it more time to receive the data (not ideal, but a first try) and hey ... no more problems since two days ...
    I will now try to make the loop a bit better by using the client below the stream and available() till 10 chars or 100ms are away ...

  8. Apollon77 commented on Nov 8, 2015

    @Apollon77
    Contributor

    So, after a month of having it working without problems ... I removed all debugging stuff and committet it.

    See pull request #15 or my fork at https://github.com/Apollon77/HTTPClient

  9. Apollon77 commented on Dec 4, 2015

    @Apollon77
    Contributor

    With merging my pull request this issue hopefully can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions