来自kaa C sdk在RPI3上的奇怪行为

我正在尝试在覆盆子pi 3上构建一个C应用程序,它收集一些传感器读数并将它们记录到mongodb日志追加器中。 我从应用程序面临一个非常奇怪的行为

这是我的应用程序代码,它是从main函数调用的

#include  #include  #include  #include  #include  #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; } 

这是我的kaa日志代码

 #include  #include  #include  #include  #include  #include  #include  #include  #include  #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; } 

行为:

  • 有时,当我运行可执行文件时,正常按预期每1秒接收一次日志,有时只接收2条日志记录
  • 如果我将kaa循环延迟时间KAA_LOG_GENERATION_FREQUENCY为任何数字(例如60),即使我再次运行可执行文件,也从未获得任何记录

这是跟踪日志

 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 

我设法解决了这个问题,我就是这样做的。 在日志初始化中,我刚删除了这一行

 error_code = kaa_logging_set_strategy(kaa_client_get_context(kaa_client_context)->log_collector, log_upload_strategy_context); 

原因可能是,kaa策略已经配置好了