This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Problem with nRF-connect-SDK http_client_req() function

Hi,


I open ssl socket to the server (without certificate verification),
and then use an http_client_req() call, to perform the actual http request (with additional optional headers).

That works fine for both http GET and POST requests, that have a short response from the server.

However, when the server's response is a bit larger (say 2.5KB not including response headers and cookie), I always get "Socket was closed by remote" error (-104).
I tried increasing recv_buf_len from 1KB to 8KB, but it didn't help.

When debugging http_client_req(), I see that the call to socket's recv() just returns 0 bytes, which is considered socket close by remote.
On the server logs I see that HTTP request, but no special problems appear on aws elb logs.

Performing the same request on my PC (using Postman for example), works just fine, so the problem is not on the server side (at least not with standard http/tcp settings)/

thanks in advance..


Parents Reply Children
  • Hi,

    In order to make sure that it is not some kind of bug caused by our application, I now used your https_client sample application (slightly modified for our test).
    This (sample) application doesn't even use the http_client library, it works directly with sockets send() and recv() calls (which http_client uses underneath).

    And the same problem happened there as well. So it does seem like a real problem with the modem/secured-sockets SDK implementation.


    I added the application logs and the modem traces, of both cases: one with none-secured-sockets (=http) that worked fine, and one with secured sockets (https ssl) that got 0 bytes from the server (which closes the socket by remote):

    *** Booting Zephyr OS build v2.4.99-ncs2  ***
    Flash regions           Domain          Permissions
    00 00 0x00000 0x08000   Secure          rwxl
    01 31 0x08000 0x100000  Non-Secure      rwxl
    
    Non-secure callable region 0 placed in flash region 0 with size 32.
    
    SRAM region             Domain          Permissions
    00 07 0x00000 0x10000   Secure          rwxl
    08 31 0x10000 0x40000   Non-Secure      rwxl
    
    Peripheral              Domain          Status
    00 NRF_P0               Non-Secure      OK
    01 NRF_CLOCK            Non-Secure      OK
    02 NRF_RTC0             Non-Secure      OK
    03 NRF_RTC1             Non-Secure      OK
    04 NRF_NVMC             Non-Secure      OK
    05 NRF_UARTE1           Non-Secure      OK
    06 NRF_UARTE2           Secure          SKIP
    07 NRF_TWIM2            Non-Secure      OK
    08 NRF_SPIM3            Non-Secure      OK
    09 NRF_TIMER0           Non-Secure      OK
    10 NRF_TIMER1           Non-Secure      OK
    11 NRF_TIMER2           Non-Secure      OK
    12 NRF_SAADC            Non-Secure      OK
    13 NRF_PWM0             Non-Secure      OK
    14 NRF_PWM1             Non-Secure      OK
    15 NRF_PWM2             Non-Secure      OK
    16 NRF_PWM3             Non-Secure      OK
    17 NRF_WDT              Non-Secure      OK
    18 NRF_IPC              Non-Secure      OK
    19 NRF_VMC              Non-Secure      OK
    20 NRF_FPU              Non-Secure      OK
    21 NRF_EGU1             Non-Secure      OK
    22 NRF_EGU2             Non-Secure      OK
    23 NRF_DPPIC            Non-Secure      OK
    24 NRF_REGULATORS       Non-Secure      OK
    25 NRF_GPIOTE1          Non-Secure      OK
    
    SPM: NS image at 0xc000
    SPM: NS MSP at 0x200211d8
    SPM: NS reset vector at 0xece9
    SPM: prepare to jump to Non-Secure image.
    *** Booting Zephyr OS build v2.4.99-ncs2  ***
    HTTPS client sample started
    Provisioning certificate
    Waiting for network.. OK
    Connecting to testep.free.beeceptor.com
    Sent 78 bytes
    Received 8142 bytes
    
    >        HTTP/1.1 200 OK
    
    Finished, closing socket.
    none_secure_sock_trace-2021-07-15T00-42-13.023Z.bin
    *** Booting Zephyr OS build v2.4.99-ncs2  ***
    Flash regions           Domain          Permissions
    00 00 0x00000 0x08000   Secure          rwxl
    01 31 0x08000 0x100000  Non-Secure      rwxl
    
    Non-secure callable region 0 placed in flash region 0 with size 32.
    
    SRAM region             Domain          Permissions
    00 07 0x00000 0x10000   Secure          rwxl
    08 31 0x10000 0x40000   Non-Secure      rwxl
    
    Peripheral              Domain          Status
    00 NRF_P0               Non-Secure      OK
    01 NRF_CLOCK            Non-Secure      OK
    02 NRF_RTC0             Non-Secure      OK
    03 NRF_RTC1             Non-Secure      OK
    04 NRF_NVMC             Non-Secure      OK
    05 NRF_UARTE1           Non-Secure      OK
    06 NRF_UARTE2           Secure          SKIP
    07 NRF_TWIM2            Non-Secure      OK
    08 NRF_SPIM3            Non-Secure      OK
    09 NRF_TIMER0           Non-Secure      OK
    10 NRF_TIMER1           Non-Secure      OK
    11 NRF_TIMER2           Non-Secure      OK
    12 NRF_SAADC            Non-Secure      OK
    13 NRF_PWM0             Non-Secure      OK
    14 NRF_PWM1             Non-Secure      OK
    15 NRF_PWM2             Non-Secure      OK
    16 NRF_PWM3             Non-Secure      OK
    17 NRF_WDT              Non-Secure      OK
    18 NRF_IPC              Non-Secure      OK
    19 NRF_VMC              Non-Secure      OK
    20 NRF_FPU              Non-Secure      OK
    21 NRF_EGU1             Non-Secure      OK
    22 NRF_EGU2             Non-Secure      OK
    23 NRF_DPPIC            Non-Secure      OK
    24 NRF_REGULATORS       Non-Secure      OK
    25 NRF_GPIOTE1          Non-Secure      OK
    
    SPM: NS image at 0xc000
    SPM: NS MSP at 0x200211d8
    SPM: NS reset vector at 0xed21
    SPM: prepare to jump to Non-Secure image.
    *** Booting Zephyr OS build v2.4.99-ncs2  ***
    HTTPS client sample started
    Provisioning certificate
    Waiting for network.. OK
    Connecting to testep.free.beeceptor.com
    Sent 79 bytes
    Received 0 bytes
    Finished, closing socket.
    secured_sock_trace-2021-07-15T00-45-45.128Z.bin

Related