Skip to content

Unable to get the Socket.IO ACK to work #879

Closed Answered by MelvinQM
MelvinQM asked this question in Q&A
Discussion options

You must be logged in to vote

I seem to have found the answer to my own problem:

The template code for the ACK seems to have a mistake.

// Message Includes a ID for a ACK (callback)
if(id) {
    // creat JSON message for Socket.IO (ack)
    DynamicJsonDocument docOut(1024);
    JsonArray array = docOut.to<JsonArray>();

    // add payload (parameters) for the ack (callback function)
    JsonObject param1 = array.createNestedObject();
    param1["now"] = millis();

    // JSON to String (serializion)
    String output;
    //output += id;
    serializeJson(docOut, output);
    output = id + output; // This worked as a fix for me

    // Send event
    socketIO.send(sIOtype_ACK, output);
}

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by MelvinQM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant