Hello Arduino Community,
I hope you're all doing well. I'm facing a peculiar issue with my Arduino-based NTRIP client, and I'm seeking some guidance to resolve it. I've provided a detailed description of the problem below, and any insights or suggestions would be greatly appreciated.
Problem Description:
I've been working on an Arduino project that involves sending NTRIP requests to a server. The requests are crucial for my application, and I've been able to successfully send similar requests to other servers using my Arduino board. However, I've encountered an issue when trying to send a specific NTRIP request to a particular server.
The Issue:
When sending the NTRIP request using my Arduino board, the server appears to receive the request in multiple chunks. Specifically, the request is being split at certain points, leading to incorrect parsing by the server. Strangely, I've tested the same request using other tools (Python TCP client, Hercules TCP client), and the server receives the request intact without any splitting issues. This suggests that the problem is specific to the way my Arduino board is sending the request.
The other weird thing is that the server does receive the complete entire request from my arduino board sometimes like once in 30 try I would say. And when I try to reupload the program on the arduino board without changing anything after a success, the request is seen splitted. I have access to the server log which displays every incoming data.
Current Approach:
I'm using the MKRNB library for cellular communication and the NBClient class to establish the connection to the server. I construct the NTRIP request as a string and use the client.print() method to send it. However, despite my efforts, the server still receives the request in fragmented chunks.
What I've Tried:
- I've experimented with adding small delays after sending each part of the request, but this didn't resolve the issue.
- I've tried using the
client.write()method to send the request as bytes, but the problem persists. - I've tried using the
client.print()method to send the request as bytes, but the problem persists. - I've tried sending HTTP POST request to the same server and the request was still getting splitted.
- I've tried sending request to webhook.site to test if the request was correctly received and it worked just great. Which makes me believe the problem could be on the server-side, but when I send the request with other TCP client tool the server answers me correctly and the log displays one unique message.
Code Snippet:
Here's a simplified version of the code I'm using:
#include <MKRNB.h>
const char server[] = server_ip;
const int port = server_port;
NBClient client;
NB nbAccess(true);
GPRS gprs;
void setup() {
// Initialization code here...
}
void loop() {
if (!client.connected()) {
if (client.connect(server, port)) {
const char sourceRequest[] = "content";
client.print(sourceRequest); // Sending the request
}
else {
// Error handling...
}
}
// Reading and processing response...
}
Debug
The debug mode of the nbAccess showed me the different AT command that are being used and I can see that the AT+USOWR is used only once which is the command to write to the server. That means the request is sent in one unique packet I guess.
Request for Help:
I'm reaching out to the Arduino community for any insights into why the server might be receiving the NTRIP request in fragmented chunks when sent from my Arduino board. If anyone has encountered a similar issue or has any suggestions on how to ensure the server receives the request intact, I would be extremely grateful for your guidance.
Thank you in advance for your time and assistance. I'm looking forward to hearing your thoughts on this matter.
Best regards,
Etienne