I am having an issue with receiving a data stream. I had started out with using the MQTT sample and experienced this issue, so I decided to strip it down to strictly a TCP TLS socket and do some testing.
HW: PCA10090 0.8.2 and custom PCB
Modem firmware: mfw_nrf9160_0.7.0-15.alpha.
Zephyr OS: v1.13.99-ncs1-6042-ga288e8b8ab54
The nRF9160 is configured as a TCP client and provisioned with the CA certificate, client private key, and client certificate. After successful connection to the server, the server begins sending a byte stream and the client echos. If sent in small chunks (~64 bytes) the connection seems to last longer, but will eventually stall at 2-4kB total bytes sent. The connection immediately stalls sending anything large (2048 byte chunks) at once. I don't seem to get any error/failures on client or server.
I am debugging with SWD and Segger RTT and noticed errata 17 (https://infocenter.nordicsemi.com/topic/errata_nRF9160_EngA/ERR/nRF9160/EngineeringA/latest/anomaly_160_17.html) and implemented the workaround, but had no effect on the symptoms.
I also followed the blog post regarding modem trace (https://devzone.nordicsemi.com/b/blog/posts/how-to-get-modem-trace-using-trace-collector-in-nrf-connect). Attached is a trace file.trace-2019-05-08T22-58-18.451Z.bin
Here is my code that makes the TCP TLS client socket. It uses the functions implemented in the MQTT library.
printk("Connecting...\n");
err = mqtt_client_tls_connect(&client);
if (err) {
printk("Error connecting: %d\n", err);
return;
}
printk("Connected.\n");
printk("Initializing fds for polling...\n");
err = fds_init(&client);
if (err) {
printk("Error initializing fds: %d\n", err);
return;
}
printk("Initialized fds.\n");
for (;;) {
ret = mqtt_client_tls_read(&client, buf, sizeof(buf));
if (ret == -EAGAIN) {
for (;;) {
printk("Polling...\n");
err = poll(&fds, 1, 1000);
if (err) {
printk("Poll breaking maneuver...\n");
break;
}
}
if (err < 0) {
printk("Error polling: %d\n", err);
break;
}
if ((fds.revents & POLLERR) == POLLERR) {
printk("POLLERR\n");
break;
} else if ((fds.revents & POLLNVAL) == POLLNVAL) {
printk("POLLNVAL\n");
break;
} else if ((fds.revents & POLLIN) == POLLIN) {
printk("POLLIN\n");
} else {
printk("Another kind of POLL...\n");
}
} else if (ret == 0) {
printk("Connection appears to be closed.\n");
break;
} else if (ret > 0) {
printk("Read %d bytes.\n", ret);
len = ret;
printk("Writing %d bytes.\n", len);
err = mqtt_client_tls_write(&client, buf, len);
if (err) {
printk("Error writing: %d\n", err);
break;
}
} else {
printk("Error reading: %d\n", ret);
break;
}
}
printk("Disconnecting...\n");
err = mqtt_client_tls_disconnect(&client);
if (err) {
printk("Error disconnecting: %d", err);
return;
}
printk("Disconnected.\n");
Anyone else having similar issues? I have done some simple testing with plain TCP and have not experienced this stalling.