golioth / golioth-zephyr-sdk

Golioth SDK For Zephyr
https://www.golioth.io
Apache License 2.0
65 stars 20 forks source link

Will not receive data using offloaded socket/TLS on nRF9160 #417

Closed jaredwolff closed 11 months ago

jaredwolff commented 11 months ago

Zephyr Commit hash

28a3fca7da5cfb3b72f1a874b3b7fa62f713ab3d

Golioth SDK Commit Hash

bbae6f8419ed52acd74784ed7e876a0f24e75f8b

Hardware Target

circuitdojo_feather_nrf9160_ns

What host OS are you using?

❯ cat /etc/os-release
NAME="Pop!_OS"
VERSION="22.04 LTS"
ID=pop
ID_LIKE="ubuntu debian"
PRETTY_NAME="Pop!_OS 22.04 LTS"
VERSION_ID="22.04"
HOME_URL="https://pop.system76.com"
SUPPORT_URL="https://support.system76.com"
BUG_REPORT_URL="https://github.com/pop-os/pop/issues"
PRIVACY_POLICY_URL="https://system76.com/privacy"
VERSION_CODENAME=jammy
UBUNTU_CODENAME=jammy
LOGO=distributor-logo-pop-os

Current Behavior

I'm trying to use the offloaded socket/TLS through the modem firmware on the nRF9160. I get a successful connection but when the client goes to receive data the connection fails:

[00:00:07.388,732] <inf> modem: Disconnected
[00:00:07.388,763] <inf> modem: LTE cell changed: Cell ID: 13379857, Tracking area: 1544
[00:00:10.768,463] <inf> modem: Network registration status: Connected - roaming
[00:00:10.768,768] <inf> golioth_system: Starting connect
[00:00:10.769,714] <inf> modem: Sleep PSM
[00:00:15.767,028] <inf> app: Connected to Golioth!
[00:00:15.767,089] <inf> app: Sending hello! 0
[00:00:15.767,700] <inf> golioth_system: Client connected!
[00:00:16.067,169] <err> golioth_system: Failed to receive: -95

The error message -95 corresponds to the error code EOPNOTSUPP, which stands for "Operation not supported".

While looking into the depths of the API documentation, it looks like ZSOCK_MSG_TRUNC is not supported by nrfxlib

Expected Behavior

The Golioth client connect and receive data without issue when using offloaded sockets/TLS.

Steps To Reproduce

Set

CONFIG_NET_SOCKETS_OFFLOAD=y
CONFIG_NET_SOCKETS_POSIX_NAMES=y

In config. Do not modify CONFIG_NET_SOCKETS_TLS_PRIORITY since we want the offloaded sockets.

Set the supported cipher suite:

CONFIG_GOLIOTH_CIPHERSUITES="TLS_PSK_WITH_AES_128_CBC_SHA256"

Load PSK to the device using AT%CMNG AT command.

Then try connecting.

Logs, console output, or any kind of debug information

Removing the usage of `ZSOCK_MSG_TRUNC` allows the offloaded socket/(D)TLS connection to work.
jaredwolff commented 11 months ago

Now connecting OK with the ZSOCK_MSG_TRUNC flag removed.

image