• Support
  • HTTP Post in MQTT Simple example fails

I am using the https_client example, connecting to AWS and sending to a presigned URL.
I am trying to send 230k bytes. The transfer works fine.

I need to also connect to an MQTT server. I use mqtt_simple. It can stay connected and I can send data to the AWS MQTT server all day long.

When the mqtt server sends a certain messages, I need to do an https put like that in the https client example.

I do this is a separate thread. I can send small files, but when I start sending more than 30k, two things happen. The MQTT connection drops and the file transfer gets a transfer error for one of the packets.

Can I have two sockets open at the same time?
Do I need to increase the stack or heap or something?
Is there any ways to find out why these failures are occurring?

Thanks,

modem_key_mgmt_exists
Provisioning certificate
Waiting for network.. OK
tls_setup
Connecting to powersighta118a3c3f62e4994aecfa01048f2d7d032334-dev.s3.us-west-1.amazonaws.com
PUT /PS3550-03037_1723343823202.%24LO?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Content-Sha256=UNSIGNED-PAYLOAD&X-Amz-Credential=AKIAWGYN4BC5JC356DPT%2F20240811%2Fus-west-1%2Fs3%2Faws4_request&X-Amz-Date=20240811T023703Z&X-Amz-Expires=3600&X-Amz-Signature=6180c737471b9dbcc11a5a46d4efbc48fef26dfd89ef161f1c7099087f26d9f7&X-Amz-SignedHeaders=host&x-id=PutObject HTTP/1.1
Host: powersighta118a3c3f62e4994aecfa01048f2d7d032334-dev.s3.us-west-1.amazonaws.com
Content-Type: application/octet-stream
Content-Length: 130128
Connection: close

Sent 0 bytes out of 130128
Sent 256 bytes out of 130128
Sent 512 bytes out of 130128
Sent 768 bytes out of 130128
...
Sent 129792 bytes out of 130128
Sent 130048 bytes out of 130128
Sent 130843 bytes
Do recv
Received 330 bytes

>        HTTP/1.1 200 OK

Finished, closing socket.`

    RichSurprenant Can I have two sockets open at the same time?

    As far as I know you can have multiple sockets open. I’ve had mixed experience with it in the past depending on what SDK version you’re using. It’s also highly depending on how you’re servicing data to and from those sockets. If you steal away all processing from one of the sockets you’ll get issues.

    For instance the processing of MQTT data usually runs in its own thread and HTTP will run in whatever thread you called it from. If you are blocking in either one you’ll starve out the other.

    Is there any ways to find out why these failures are occurring?

    You may be able to run a modem trace

    https://docs.circuitdojo.com/nrf9160-programming-and-debugging.html?highlight=trace#getting-a-modem-trace

    You do need a custom version of the cellular monitor if you want to go that direction. I have one here that I’ve been testing. Happy to share.

      Terms and Conditions | Privacy Policy