问题
I am trying to build a C application on a raspberry pi 3 which collects some sensors readings and log them into a mongodb log appender. I am facing a very strange behavior from the application
Here is my application code which is called from the main function
#include <stdio.h>
#include <stdlib.h>
#include <kaa/kaa.h>
#include <kaa/platform/kaa_client.h>
#include <kaa/kaa_error.h>
#include "dht11.h"
#include "kaa-log.h"
#define KAA_LOG_GENERATION_FREQUENCY 1 // in seconds
/*
* Pin on Rasbery Pi 3 Model B
*/
#define DHT11_PIN 7
static void kaa_loop(void *context)
{
static bool logInitialized = false;
kaa_client_t *kaa_client = context;
if (!logInitialized)
{
logInitialized = true;
kaaLogInitializing(kaa_client);
}
if (logDelivered != LOG_DELIVERY_DELIVERING)
{
logDelivered = LOG_DELIVERY_IDLE;
read_dht11_dat();
sendLog(kaa_client);
}
//kaa_client_stop(context);
}
uint8_t kaa_application_start()
{
printf("Starting kaa application\n");
kaa_client_t *kaa_client = NULL;
kaa_error_t error = kaa_client_create(&kaa_client, NULL);
if (error) {
return EXIT_FAILURE;
}
error = kaa_client_start(kaa_client, kaa_loop, (void *)kaa_client, KAA_LOG_GENERATION_FREQUENCY);
kaa_client_destroy(kaa_client);
if (error) {
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
and here is my kaa log code
#include <stdio.h>
#include <kaa/kaa.h>
#include <kaa/platform/kaa_client.h>
#include <kaa/kaa_error.h>
#include <extensions/logging/kaa_logging.h>
#include <kaa/platform-impl/common/ext_log_upload_strategies.h>
#include <extensions/logging/kaa_logging_private.h>
#include <kaa/gen/kaa_logging_gen.h>
#include <kaa/utilities/kaa_mem.h>
#include "kaa-log.h"
#define LOG_UPLOAD_THRESHOLD 1
#define MAX_LOG_BUCKET_SIZE SIZE_MAX
#define MAX_LOG_COUNT 5
uint8_t logDelivered = LOG_DELIVERY_IDLE;
/* Set of routines that handles log delivery events */
static void success_log_delivery_callback(void *context, const kaa_log_bucket_info_t *bucket)
{
/* ... */
logDelivered = LOG_DELIVERY_DELIVERED_SUCCESS;
printf("Log Sent\n");
// kaa_client_t * kaa_client_context = context;
// kaa_client_stop(kaa_client_context);
}
static void failed_log_delivery_callback(void *context, const kaa_log_bucket_info_t *bucket)
{
/* ... */
logDelivered = LOG_DELIVERY_DELIVERED_FAILURE;
printf("Log Failure\n");
// kaa_client_t * kaa_client_context = context;
// kaa_client_stop(kaa_client_context);
}
static void timeout_log_delivery_callback(void *context, const kaa_log_bucket_info_t *bucket)
{
/* ... */
logDelivered = LOG_DELIVERY_DELIVERED_TIMEOUT;
printf("Log Timeout\n");
// kaa_client_t * kaa_client_context = context;
// kaa_client_stop(kaa_client_context);
}
void kaaLogInitializing(void *context)
{
void *log_storage_context = NULL;
void *log_upload_strategy_context = NULL;
printf("Initializing the Kaa log\n");
kaa_client_t * kaa_client_context = context;
if (context == NULL) {
return;
}
/* Log delivery listener callbacks. Each callback called whenever something happen with a log bucket. */
kaa_log_delivery_listener_t log_listener = {
.on_success = success_log_delivery_callback, /* Called if log delivered successfully */
.on_failed = failed_log_delivery_callback, /* Called if delivery failed */
.on_timeout = timeout_log_delivery_callback, /* Called if timeout occurs */
.ctx = kaa_client_context, /* Optional context */
};
/* The internal memory log storage distributed with Kaa SDK */
kaa_error_t error_code = ext_unlimited_log_storage_create(&log_storage_context,
kaa_client_get_context(
kaa_client_context
)->logger
);
if (error_code) {
printf("Failed to create Kaa log storage %d\r\n", error_code);
return;
}
error_code = ext_log_upload_strategy_create(kaa_client_get_context(
kaa_client_context),
&log_upload_strategy_context, KAA_LOG_UPLOAD_VOLUME_STRATEGY);
if (error_code) {
printf("Failed to create log upload strategy, error code %d\r\n", error_code);
return;
}
error_code = ext_log_upload_strategy_set_threshold_count(log_upload_strategy_context,
LOG_UPLOAD_THRESHOLD);
if (error_code) {
printf("Failed to set threshold log record count, error code %d\r\n", error_code);
return;
}
error_code = kaa_logging_set_strategy(kaa_client_get_context(kaa_client_context)->log_collector,
log_upload_strategy_context);
if (error_code) {
printf("Failed to set log upload strategy, error code %d\r\n", error_code);
return;
}
/* Specify log bucket size constraints */
kaa_log_bucket_constraints_t bucket_sizes = {
.max_bucket_size = MAX_LOG_BUCKET_SIZE, /* Bucket size in bytes */
.max_bucket_log_count = MAX_LOG_COUNT, /* Maximum log count in one bucket */
};
/* Initialize the log storage and strategy (by default it is not set) */
error_code = kaa_logging_init(kaa_client_get_context(
kaa_client_context)->log_collector
, log_storage_context
, log_upload_strategy_context
, &bucket_sizes);
if (error_code) {
printf("Failed to initialize Kaa log %d\r\n", error_code);
return;
}
/* Add listeners to a log collector */
kaa_logging_set_listeners(kaa_client_get_context(
kaa_client_context)->log_collector,
&log_listener);
}
void sendLog(void *context)
{
kaa_client_t * kaa_client_context = context;
double *p_temperature = KAA_MALLOC(sizeof(double));
if (!p_temperature) {
// error handling
}
*p_temperature = 25.5;
if (context == NULL) {
return;
}
logDelivered = LOG_DELIVERY_DELIVERING;
printf("Start attempt to send Log\n");
kaa_logging_remote_sensor_log_t *log_record = kaa_logging_remote_sensor_log_create();
log_record->device_id = kaa_string_copy_create("Dev1");
log_record->temperature = kaa_logging_union_double_or_null_branch_0_create();
log_record->temperature->data = p_temperature; /* create subobject */
log_record->humidity = kaa_logging_union_long_or_null_branch_1_create();
log_record->battery_level = kaa_logging_union_int_or_null_branch_1_create();
printf("Log record created\n");
/* Log information. Populated when log is added via kaa_logging_add_record() */
kaa_log_record_info_t log_info;
kaa_error_t error = kaa_logging_add_record(
kaa_client_get_context(kaa_client_context)->log_collector,
log_record, &log_info);
if (error) {
printf("Failed to add log record, error code\r\n");
kaa_client_stop(kaa_client_context);
return;
}
log_record->destroy(log_record);
logDelivered = LOG_DELIVERY_IDLE;
}
Behavior:
- Sometimes when I run executable the log is received normally every 1 sec as expected and sometimes only receive 2 log records
- If I changed the kaa loop delay time
KAA_LOG_GENERATION_FREQUENCY
to any number for example 60, I never get any record even if I run the executable again
Here is the trace log
2017/02/14 1:30:12 [TRACE] [kaa_client.c:402] (0) - Channel [0x79303301] initialized successfully (type 1)
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
Initializing the Kaa log
2017/02/14 1:30:12 [DEBUG] [kaa_logging.c:383] (0) - Initialized log collector with log storage {0x20f7c8}, log upload strategy {0x20f5f8}
Data not good, skip
Start attempt to send Log
Log record created
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:566] (0) - Added log record, size 0, bucket 1
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:850] (0) - Kaa TCP channel new access point [0x929A2016] destination resolved
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1489] (0) - Kaa TCP channel [0x929A2016] connecting to the server...
2017/02/14 1:30:12 [TRACE] [kaa_client.c:270] (0) - Channel [0x79303301] successfully connected
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:12 [TRACE] [kaa_client.c:235] (0) - Processing OUT event for the client socket 4
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:740] (0) - Kaa TCP channel [0x929A2016] socket was successfully connected
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1156] (0) - Calling kaa_platform_protocol_alloc_serialize_client_sync
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:245] (0) - Serializing client sync...
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:72] (0) - Going to serialize client meta sync
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:111] (0) - Meta sync: payload length '76', request id '2'
2017/02/14 1:30:12 [TRACE] [kaa_notification_manager.c:505] (0) - Going to serialize client notification sync
2017/02/14 1:30:12 [TRACE] [kaa_notification_manager.c:520] (0) - Going to serialize 0 topic states
2017/02/14 1:30:12 [TRACE] [kaa_notification_manager.c:532] (0) - Going to serialize 0 uids
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:655] (0) - Going to serialize client logging sync
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:686] (0) - Extracting log records... (bucket size 34)
2017/02/14 1:30:12 [INFO] [kaa_logging.c:733] (0) - Created log bucket: id '1', log records count 1, payload size 36
2017/02/14 1:30:12 [TRACE] [kaa_event.c:695] (0) - Going to serialize client event sync
2017/02/14 1:30:12 [TRACE] [kaa_event.c:701] (0) - Going to sync event SQN
2017/02/14 1:30:12 [TRACE] [kaa_configuration_manager.c:220] (0) - Going to serialize client configuration sync
2017/02/14 1:30:12 [TRACE] [kaa_user.c:435] (0) - Going to serialize client user sync
2017/02/14 1:30:12 [TRACE] [kaa_profile.c:281] (0) - Going to compile profile client sync
2017/02/14 1:30:12 [TRACE] [kaa_profile.c:326] (0) - Writing public key (size 294)...
2017/02/14 1:30:12 [INFO] [kaa_platform_protocol.c:256] (0) - Client sync serialized: request id '2', payload size '504'
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1180] (0) - Kaa TCP channel [0x929A2016] going to send CONNECT message (512 bytes)
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1242] (0) - Kaa TCP channel [0x929A2016] created CONNECT message (1045 bytes)
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:12 [TRACE] [kaa_client.c:235] (0) - Processing OUT event for the client socket 4
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1651] (0) - Kaa TCP channel [0x929A2016] writing 1045 bytes to the socket
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1661] (0) - Kaa TCP channel [0x929A2016] 1045 bytes were successfully written
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:12 [TRACE] [kaa_client.c:226] (0) - Processing IN event for the client socket 4
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:680] (0) - Kaa TCP channel [0x929A2016] successfully read 4 bytes
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:954] (0) - Kaa TCP channel [0x929A2016] successfully authorized
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:12 [TRACE] [kaa_client.c:226] (0) - Processing IN event for the client socket 4
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:680] (0) - Kaa TCP channel [0x929A2016] successfully read 126 bytes
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1015] (0) - Kaa TCP channel [0x929A2016] KAASYNC message received
2017/02/14 1:30:12 [INFO] [kaa_platform_protocol.c:271] (0) - Server sync received: payload size '104'
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:326] (0) - Server sync request id 2
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:340] (0) - Server resync request 0
2017/02/14 1:30:12 [INFO] [kaa_profile.c:372] (0) - Received profile server sync: options 0, payload size 0
2017/02/14 1:30:12 [INFO] [kaa_profile.c:387] (0) - Endpoint has been registered
2017/02/14 1:30:12 [INFO] [kaa_user.c:554] (0) - Received user server sync: options 0, payload size 0
2017/02/14 1:30:12 [INFO] [kaa_configuration_manager.c:249] (0) - Received configuration server sync: options 2, payload size 24
2017/02/14 1:30:12 [INFO] [kaa_configuration_manager.c:255] (0) - Received configuration body, size '17'
2017/02/14 1:30:12 [TRACE] [kaa_channel_manager.c:346] (0) - Transport channel [0x79303301] for service 5 was found
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:352] (0) - Kaa TCP channel [0x929A2016] sync for 1 services
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1375] (0) - Kaa TCP channel [0x929A2016] 0 pending services, going to update 1 services
2017/02/14 1:30:12 [INFO] [kaa_notification_manager.c:1200] (0) - Received notification server sync: options 0, payload size 12
2017/02/14 1:30:12 [TRACE] [kaa_notification_manager.c:1208] (0) - Received delta response: NO DELTA. Going to clear uids list...
2017/02/14 1:30:12 [INFO] [kaa_notification_manager.c:1307] (0) - Received topics list. Topics count is 0
2017/02/14 1:30:12 [INFO] [kaa_notification_manager.c:1223] (0) - Received notifications. Notifications count is 0
2017/02/14 1:30:12 [TRACE] [kaa_channel_manager.c:346] (0) - Transport channel [0x79303301] for service 6 was found
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:352] (0) - Kaa TCP channel [0x929A2016] sync for 1 services
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1375] (0) - Kaa TCP channel [0x929A2016] 1 pending services, going to update 1 services
2017/02/14 1:30:12 [INFO] [kaa_event.c:893] (0) - Received event server sync: options 1, payload size 4
2017/02/14 1:30:12 [INFO] [kaa_event.c:906] (0) - Received event sequence number '0'
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:386] (0) - Server sync successfully processed
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:12 [TRACE] [kaa_client.c:235] (0) - Processing OUT event for the client socket 4
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1651] (0) - Kaa TCP channel [0x929A2016] writing 0 bytes to the socket
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:778] (0) - Kaa TCP channel [0x929A2016] going to sync all services
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1547] (0) - Kaa TCP channel [0x929A2016] going to serialize 2 pending services
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:245] (0) - Serializing client sync...
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:72] (0) - Going to serialize client meta sync
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:111] (0) - Meta sync: payload length '76', request id '3'
2017/02/14 1:30:12 [TRACE] [kaa_notification_manager.c:505] (0) - Going to serialize client notification sync
2017/02/14 1:30:12 [TRACE] [kaa_notification_manager.c:520] (0) - Going to serialize 0 topic states
2017/02/14 1:30:12 [TRACE] [kaa_notification_manager.c:532] (0) - Going to serialize 0 uids
2017/02/14 1:30:12 [TRACE] [kaa_configuration_manager.c:220] (0) - Going to serialize client configuration sync
2017/02/14 1:30:12 [INFO] [kaa_platform_protocol.c:256] (0) - Client sync serialized: request id '3', payload size '132'
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1587] (0) - Kaa TCP channel [0x929A2016] serialized client sync (144 bytes)
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1329] (0) - Kaa TCP channel [0x929A2016] 2 pending services, going to delete 2 services
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1627] (0) - Kaa TCP channel [0x929A2016] going to send KAASYNC message (144 bytes)
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1651] (0) - Kaa TCP channel [0x929A2016] writing 159 bytes to the socket
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1661] (0) - Kaa TCP channel [0x929A2016] 159 bytes were successfully written
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:12 [TRACE] [kaa_client.c:226] (0) - Processing IN event for the client socket 4
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:680] (0) - Kaa TCP channel [0x929A2016] successfully read 62 bytes
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1015] (0) - Kaa TCP channel [0x929A2016] KAASYNC message received
2017/02/14 1:30:12 [INFO] [kaa_platform_protocol.c:271] (0) - Server sync received: payload size '40'
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:326] (0) - Server sync request id 2
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:340] (0) - Server resync request 0
2017/02/14 1:30:12 [INFO] [kaa_logging.c:764] (0) - Received logging server sync: options 0, payload size 8
2017/02/14 1:30:12 [INFO] [kaa_logging.c:774] (0) - Received 1 log delivery statuses
2017/02/14 1:30:12 [INFO] [kaa_logging.c:799] (0) - Log bucket uploaded successfully, id '1'
Log Sent
2017/02/14 1:30:12 [INFO] [kaa_logging.c:427] (0) - Initiating log upload...
2017/02/14 1:30:12 [TRACE] [kaa_channel_manager.c:346] (0) - Transport channel [0x79303301] for service 4 was found
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:352] (0) - Kaa TCP channel [0x929A2016] sync for 1 services
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1375] (0) - Kaa TCP channel [0x929A2016] 0 pending services, going to update 1 services
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:386] (0) - Server sync successfully processed
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:12 [TRACE] [kaa_client.c:235] (0) - Processing OUT event for the client socket 4
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1651] (0) - Kaa TCP channel [0x929A2016] writing 0 bytes to the socket
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:778] (0) - Kaa TCP channel [0x929A2016] going to sync all services
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1547] (0) - Kaa TCP channel [0x929A2016] going to serialize 1 pending services
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:245] (0) - Serializing client sync...
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:72] (0) - Going to serialize client meta sync
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:111] (0) - Meta sync: payload length '76', request id '4'
2017/02/14 1:30:12 [INFO] [kaa_platform_protocol.c:256] (0) - Client sync serialized: request id '4', payload size '92'
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1587] (0) - Kaa TCP channel [0x929A2016] serialized client sync (96 bytes)
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1329] (0) - Kaa TCP channel [0x929A2016] 1 pending services, going to delete 1 services
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1627] (0) - Kaa TCP channel [0x929A2016] going to send KAASYNC message (96 bytes)
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1651] (0) - Kaa TCP channel [0x929A2016] writing 110 bytes to the socket
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1661] (0) - Kaa TCP channel [0x929A2016] 110 bytes were successfully written
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:12 [TRACE] [kaa_client.c:226] (0) - Processing IN event for the client socket 4
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:680] (0) - Kaa TCP channel [0x929A2016] successfully read 78 bytes
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1015] (0) - Kaa TCP channel [0x929A2016] KAASYNC message received
2017/02/14 1:30:12 [INFO] [kaa_platform_protocol.c:271] (0) - Server sync received: payload size '48'
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:326] (0) - Server sync request id 3
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:340] (0) - Server resync request 0
2017/02/14 1:30:12 [INFO] [kaa_configuration_manager.c:249] (0) - Received configuration server sync: options 0, payload size 0
2017/02/14 1:30:12 [INFO] [kaa_notification_manager.c:1200] (0) - Received notification server sync: options 0, payload size 8
2017/02/14 1:30:12 [TRACE] [kaa_notification_manager.c:1208] (0) - Received delta response: NO DELTA. Going to clear uids list...
2017/02/14 1:30:12 [INFO] [kaa_notification_manager.c:1223] (0) - Received notifications. Notifications count is 0
2017/02/14 1:30:12 [TRACE] [kaa_channel_manager.c:346] (0) - Transport channel [0x79303301] for service 6 was found
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:352] (0) - Kaa TCP channel [0x929A2016] sync for 1 services
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1375] (0) - Kaa TCP channel [0x929A2016] 0 pending services, going to update 1 services
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:386] (0) - Server sync successfully processed
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:12 [TRACE] [kaa_client.c:235] (0) - Processing OUT event for the client socket 4
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1651] (0) - Kaa TCP channel [0x929A2016] writing 0 bytes to the socket
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:778] (0) - Kaa TCP channel [0x929A2016] going to sync all services
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1547] (0) - Kaa TCP channel [0x929A2016] going to serialize 1 pending services
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:245] (0) - Serializing client sync...
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:72] (0) - Going to serialize client meta sync
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:111] (0) - Meta sync: payload length '76', request id '5'
2017/02/14 1:30:12 [TRACE] [kaa_notification_manager.c:505] (0) - Going to serialize client notification sync
2017/02/14 1:30:12 [TRACE] [kaa_notification_manager.c:520] (0) - Going to serialize 0 topic states
2017/02/14 1:30:12 [TRACE] [kaa_notification_manager.c:532] (0) - Going to serialize 0 uids
2017/02/14 1:30:12 [INFO] [kaa_platform_protocol.c:256] (0) - Client sync serialized: request id '5', payload size '104'
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1587] (0) - Kaa TCP channel [0x929A2016] serialized client sync (112 bytes)
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1329] (0) - Kaa TCP channel [0x929A2016] 1 pending services, going to delete 1 services
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1627] (0) - Kaa TCP channel [0x929A2016] going to send KAASYNC message (112 bytes)
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1651] (0) - Kaa TCP channel [0x929A2016] writing 126 bytes to the socket
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1661] (0) - Kaa TCP channel [0x929A2016] 126 bytes were successfully written
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:12 [TRACE] [kaa_client.c:226] (0) - Processing IN event for the client socket 4
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:680] (0) - Kaa TCP channel [0x929A2016] successfully read 46 bytes
2017/02/14 1:30:12 [TRACE] [kaa_tcp_channel.c:1015] (0) - Kaa TCP channel [0x929A2016] KAASYNC message received
2017/02/14 1:30:12 [INFO] [kaa_platform_protocol.c:271] (0) - Server sync received: payload size '24'
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:326] (0) - Server sync request id 4
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:340] (0) - Server resync request 0
2017/02/14 1:30:12 [TRACE] [kaa_platform_protocol.c:386] (0) - Server sync successfully processed
2017/02/14 1:30:12 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:13 [TRACE] [kaa_client.c:226] (0) - Processing IN event for the client socket 4
2017/02/14 1:30:13 [TRACE] [kaa_tcp_channel.c:680] (0) - Kaa TCP channel [0x929A2016] successfully read 46 bytes
2017/02/14 1:30:13 [TRACE] [kaa_tcp_channel.c:1015] (0) - Kaa TCP channel [0x929A2016] KAASYNC message received
2017/02/14 1:30:13 [INFO] [kaa_platform_protocol.c:271] (0) - Server sync received: payload size '24'
2017/02/14 1:30:13 [TRACE] [kaa_platform_protocol.c:326] (0) - Server sync request id 5
2017/02/14 1:30:13 [TRACE] [kaa_platform_protocol.c:340] (0) - Server resync request 0
2017/02/14 1:30:13 [TRACE] [kaa_platform_protocol.c:386] (0) - Server sync successfully processed
2017/02/14 1:30:13 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
Data not good, skip
Start attempt to send Log
Log record created
2017/02/14 1:30:13 [TRACE] [kaa_logging.c:566] (0) - Added log record, size 0, bucket 2
2017/02/14 1:30:13 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:14 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
Data not good, skip
Start attempt to send Log
Log record created
2017/02/14 1:30:14 [TRACE] [kaa_logging.c:566] (0) - Added log record, size 0, bucket 2
2017/02/14 1:30:14 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:15 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
Data not good, skip
Start attempt to send Log
Log record created
2017/02/14 1:30:15 [TRACE] [kaa_logging.c:566] (0) - Added log record, size 0, bucket 2
2017/02/14 1:30:15 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:16 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
Data not good, skip
Start attempt to send Log
Log record created
2017/02/14 1:30:16 [TRACE] [kaa_logging.c:566] (0) - Added log record, size 0, bucket 2
2017/02/14 1:30:16 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:17 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
Data not good, skip
Start attempt to send Log
Log record created
2017/02/14 1:30:17 [TRACE] [kaa_logging.c:566] (0) - Added log record, size 0, bucket 2
2017/02/14 1:30:17 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:18 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
Data not good, skip
Start attempt to send Log
Log record created
2017/02/14 1:30:18 [TRACE] [kaa_logging.c:566] (0) - Added log record, size 0, bucket 3
2017/02/14 1:30:18 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
2017/02/14 1:30:19 [TRACE] [kaa_logging.c:449] (0) - Upload will not be triggered now.
Data not good, skip
Start attempt to send Log
Log record created
2017/02/14 1:30:19 [TRACE] [kaa_logging.c:566] (0) - Added log record, size 0, bucket 3
回答1:
I have managed to solve this and here is how I did it. In the log initialization I just removed this line
error_code = kaa_logging_set_strategy(kaa_client_get_context(kaa_client_context)->log_collector,
log_upload_strategy_context);
The reason might be, kaa strategy has been already configured
来源:https://stackoverflow.com/questions/42216357/strange-behavior-from-kaa-c-sdk-on-rpi3