Trouble receiving binary stream data with recv()

I've been writing this FOTA solution that would work together with an existing server we use together with Onomondo connectors.

And I've been running into this issue when I'm trying to download a firmware bin file, when I try to use the recv function to retrieve the data, I'll get a few bytes that make sense, the starter byte for example, and then in between there's a loop of `239 191 189` bytes just repeating hundreds of times.

When I've tested the output from the server through Postman or just by URL, it appears to work correctly and returns the file. I am however able to return the bytes in a string format and then convert them on the device, although it's a very slow operation.

I've also setup logging on the server to verify the data that's supposedly being returned to the nrf9160, and that also appears to be correct?

Parents
  • I try to use the recv function

    Do you check the return value of the recv() function?
    Does it return success both for the "good bytes" and the "bad bytes"?

    I am however able to return the bytes in a string format and then convert them on the device, although it's a very slow operation.

    Is this for the server or the nRF9160?

    Regards,
    Sigurd Hellesvik

  • Yes it returns success for both bytes, I recv chunks of 2048 bytes at a time, and in there I'll have a mix of both. 

    I use a NodeJS express server, and if I return a binary buffer, that's when the NRF9160 gets the wrong bytes, however if I take that buffer and say turn it into a string or a hex string on the server before returning it, then I receive the data in string format correctly on the NRF9160.

    Appears to only happen when I try to recv a binary buffer on the NRF9160 from the express server, as I've tried with other formats such as JSON, and that gets handled correctly.

Reply
  • Yes it returns success for both bytes, I recv chunks of 2048 bytes at a time, and in there I'll have a mix of both. 

    I use a NodeJS express server, and if I return a binary buffer, that's when the NRF9160 gets the wrong bytes, however if I take that buffer and say turn it into a string or a hex string on the server before returning it, then I receive the data in string format correctly on the NRF9160.

    Appears to only happen when I try to recv a binary buffer on the NRF9160 from the express server, as I've tried with other formats such as JSON, and that gets handled correctly.

Children
Related