GithubHelp home page GithubHelp logo

Comments (7)

eeff avatar eeff commented on June 10, 2024

Please provide the log from neuron.log with the timestamp matches the problem you specified.
For example, around timestamp 2023-09-07 19:00:00.

Also, the version latest is not informative, please run neuron --version to provide this information.

from neuron.

jerryma0912 avatar jerryma0912 commented on June 10, 2024

Can you provide an email address? I will email the log to you
version:Neuron 2.6.0-dev (d4e9e63)

from neuron.

eeff avatar eeff commented on June 10, 2024

Can you provide an email address? I will email the log to you version:Neuron 2.6.0-dev (d4e9e63)

Did you modify the code ? If so, I hardly can draw any conclusion without information about your changes.

from neuron.

jerryma0912 avatar jerryma0912 commented on June 10, 2024

Oh yes, your question inspired me!

I have modified one thing, that is, the response format of the read request. The modified response format is consistent with the actively reported attribute format. But I'm not sure what's wrong with what I modified, can you help me?

I referred to the generate_upload_json function. The modified content is as follows:


In the neu_json_mqtt.h: the following structure is added:

typedef struct {
     char* group;
     char* node;
     uint64_t timestamp;
     char * uuid;
} json_mqtt_unify_format_t;

In the neu_json_mqtt.c: the following function is added:

int json_encode_mqtt_unify_format_resp(void *json_object, void *param)
{
    int                       ret  = 0;
    json_mqtt_unify_format_t *resp = (json_mqtt_unify_format_t *) param;
    neu_json_elem_t resp_elems[] = { {
                                     .name      = "node",
                                     .t         = NEU_JSON_STR,
                                     .v.val_str = resp->node,
                                 },
                                 {
                                     .name      = "group",
                                     .t         = NEU_JSON_STR,
                                     .v.val_str = resp->group,
                                 },
                                 {
                                     .name      = "timestamp",
                                     .t         = NEU_JSON_INT,
                                     .v.val_int = resp->timestamp,
                                 },
                                 {
                                     .name      = "uuid",
                                     .t         = NEU_JSON_STR,
                                     .v.val_str = resp->uuid,
                                 }  };
    ret = neu_json_encode_field(json_object, resp_elems,NEU_JSON_ELEM_SIZE(resp_elems));

    return ret;
}

In the mqtt_handle.c: the generate_read_resp_json function has been modified:

static char *generate_read_resp_json(neu_plugin_t *         plugin,
                                     neu_json_mqtt_t *      mqtt,
                                     neu_resp_read_group_t *data)
{
    neu_resp_tag_value_meta_t *tags     = data->tags;
    uint16_t                   len      = data->n_tag;
    char *                     json_str = NULL;

   // ------the following has been added ------
    json_mqtt_unify_format_t header   = {
        .group     = (char *) data->group,
        .node      = (char *) data->driver,
        .timestamp = global_timestamp,
        .uuid      = (char *) mqtt->uuid};
  // -----------------end-----------------

    neu_json_read_resp_t       json     = { 0 };

    if (0 != tag_values_to_json(tags, len, &json)) {
        plog_error(plugin, "tag_values_to_json fail");
        return NULL;
    }

    // ----------- the following has been modified -----------
//    neu_json_encode_with_mqtt(&json, neu_json_encode_read_resp, mqtt,
//                              neu_json_encode_mqtt_resp, &json_str);
    neu_json_encode_with_mqtt(&json, neu_json_encode_read_resp1, &header,
                          json_encode_mqtt_unify_format_resp,
                          &json_str);

    for (int i = 0; i < json.n_tag; i++) {
        if (json.tags[i].n_meta > 0) {
            free(json.tags[i].metas);
        }
    }
    // ----------------------end-------------------

    if (json.tags) {
        free(json.tags);
    }
    return json_str;
}

from neuron.

eeff avatar eeff commented on June 10, 2024

I think as long as your code does not segfault, it does not relate to the problem reported.
If you modify the code in neuron core, then probably it is not the mqtt plugin causing the problem.

from neuron.

jerryma0912 avatar jerryma0912 commented on June 10, 2024

I only modified this part of the code, the core code was not updated. So I still think that this issue has nothing to do with the content I modified.

from neuron.

jerryma0912 avatar jerryma0912 commented on June 10, 2024

I only modified this part of the code, the core code was not updated. So I still think that this issue has nothing to do with the content I modified.

I suggest use the official version to test this problem : )

from neuron.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.