Announcement

Collapse
No announcement yet.

Debugging http client

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Debugging http client

    I'm currently developing an application that acts as an https client. I can interface with the client from the terminal of my dev box using curl commands and see the proper responses, but when I send the same JSON data via ltrx_httpc_request_execute, I don't ever seem to get a response (my callback, set by ltrx_httpc_request_set_response_callback, is never called).

    I need some tips on how I can debug this situation. I don't have access to the server that I'm sending the POST to. I need to be able to see the response in order to understand what's going wrong (or right, maybe?)

    I've patterned my code after a secure_http_client demo that was in development by Mariano before he moved on.

    Best,
    Jason

  • #2
    If you call ltrx_httpc_request_set_debug() before you execute the call, it will dump everything transmitted and received for that call into the TLOG. You might also call ltrx_httpc_request_set_log_verbosity() to get a little more info on what's happening during execution.
    Erick Liska
    Lantronix Inc.

    Comment


    • #3
      Thanks! I'll give that a try. Where is the documentation for those routines?

      Comment


      • #4
        Here's what I get. I have a couple questions... Why are there two 'Content-Type' sections presented below? It should only be 'Content-Type: application/json'. Since the server sent 'Continue', does that mean that my TLS credentials are set up properly?

        Thanks for the help.

        177 I httpc.c 855 Using TLS. 06:46:39
        178 I httpc.c 949 Connected. 06:46:40
        179 I httpc_requ 312 Sending headers. 06:46:40
        180 D httpc.c 180 TX 30: 06:46:40
        181 D httpc.c 183 000000 50 4F 53 54 20 2F 74 65 | POST /te 06:46:40
        182 D httpc.c 183 000008 6C 65 67 72 61 6D 2F 6A | legram/j 06:46:40
        183 D httpc.c 183 000010 73 6F 6E 20 48 54 54 50 | son HTTP 06:46:40
        184 D httpc.c 183 000018 2F 31 2E 31 0D 0A | /1.1.. 06:46:40
        185 D httpc.c 180 TX 27: 06:46:40
        186 D httpc.c 183 000000 48 6F 73 74 3A 20 69 6E | Host: in 06:46:40
        <REDACTED DATA>
        189 D httpc.c 183 000018 70 0D 0A | p.. 06:46:40
        190 D httpc.c 180 TX 38: 06:46:40
        191 D httpc.c 183 000000 55 73 65 72 2D 41 67 65 | User-Age 06:46:40
        192 D httpc.c 183 000008 6E 74 3A 20 78 50 69 63 | nt: xPic 06:46:40
        193 D httpc.c 183 000010 6F 32 35 30 2F 33 2E 34 | o250/3.4 06:46:40
        194 D httpc.c 183 000018 20 28 4C 61 6E 74 72 6F | (Lantro 06:46:40
        195 D httpc.c 183 000020 6E 69 78 29 0D 0A | nix).. 06:46:40
        196 D httpc.c 180 TX 20: 06:46:40
        197 D httpc.c 183 000000 43 6F 6E 74 65 6E 74 2D | Content- 06:46:40
        198 D httpc.c 183 000008 54 79 70 65 3A 20 4E 55 | Type: NU 06:46:40
        199 D httpc.c 183 000010 4C 4C 0D 0A | LL.. 06:46:40
        200 D httpc.c 180 TX 32: 06:46:40
        201 D httpc.c 183 000000 43 6F 6E 74 65 6E 74 2D | Content- 06:46:40
        202 D httpc.c 183 000008 54 79 70 65 3A 20 61 70 | Type: ap 06:46:40
        203 D httpc.c 183 000010 70 6C 69 63 61 74 69 6F | plicatio 06:46:40
        204 D httpc.c 183 000018 6E 2F 6A 73 6F 6E 0D 0A | n/json.. 06:46:40
        205 D httpc.c 180 TX 21: 06:46:40
        206 D httpc.c 183 000000 43 6F 6E 74 65 6E 74 2D | Content- 06:46:40
        207 D httpc.c 183 000008 4C 65 6E 67 74 68 3A 20 | Length: 06:46:40
        208 D httpc.c 183 000010 31 30 39 0D 0A | 109.. 06:46:40
        209 D httpc.c 180 TX 22: 06:46:40
        210 D httpc.c 183 000000 45 78 70 65 63 74 3A 20 | Expect: 06:46:40
        211 D httpc.c 183 000008 31 30 30 2D 63 6F 6E 74 | 100-cont 06:46:40
        212 D httpc.c 183 000010 69 6E 75 65 0D 0A | inue.. 06:46:40
        213 D httpc.c 180 TX 2: 06:46:40
        214 D httpc.c 183 000000 0D 0A | .. 06:46:40
        215 D httpc.c 203 RX 25: 06:46:40
        216 D httpc.c 206 000000 48 54 54 50 2F 31 2E 31 | HTTP/1.1 06:46:40
        217 D httpc.c 206 000008 20 31 30 30 20 43 6F 6E | 100 Con 06:46:40
        218 D httpc.c 206 000010 74 69 6E 75 65 0D 0A 0D | tinue... 06:46:40
        219 D httpc.c 206 000018 0A | . 06:46:40
        220 I httpc_requ 320 Sending content payload. 06:46:40
        221 I httpc.c 685 Sending content from buffer. 06:46:40
        222 D httpc.c 180 TX 109: 06:46:40
        <REDACTED DATA>
        236 D httpc.c 183 000068 38 22 7D 5D 7D | 8"}]} 06:46:40
        237 I httpc_requ 337 Receiving response. 06:46:40
        238 D httpc.c 203 RX 0: 06:47:10

        Comment


        • #5
          The content-type is set in the request with ltrx_httpc_request_add_mime_type(). The content-type header is always sent, even if the caller has not set the mime type. Which is a bug. I suspect you're setting it yourself with ltrx_httpc_request_add_header()? So it's sending the unset mime type (NULL), plus your header.
          Erick Liska
          Lantronix Inc.

          Comment


          • #6
            You're correct. Thank you.

            I added the call to ltrx_httpc_request_add_mime_type("application/json") and all is working. Is there any documentation for the http client other than the header file?

            Comment

            Working...
            X