You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I found that the async_publish_time.cpp file cannot send timestamp messages correctly.
To find out why, I canceled the "send when dissconnected" connect option. It showed me that connection had been closed before publishment.
the code here is what I changed.
auto createOpts = mqtt::create_options_builder()
.send_while_disconnected(true, true)
.max_buffered_messages(MAX_BUFFERED_MESSAGES)
.delete_oldest_messages()
.finalize();
I change this part of code into this:
auto createOpts = mqtt::create_options_builder()
// .send_while_disconnected(true, true)
.max_buffered_messages(MAX_BUFFERED_MESSAGES)
.delete_oldest_messages()
.finalize();
Then I compile and execute this code, still can not receive message on server side.
This is part of code from "async_publish.cpp"
I found that the async_publish_time.cpp file cannot send timestamp messages correctly.
To find out why, I canceled the "send when dissconnected" connect option. It showed me that connection had been closed before publishment.
the code here is what I changed.
auto createOpts = mqtt::create_options_builder()
.send_while_disconnected(true, true)
.max_buffered_messages(MAX_BUFFERED_MESSAGES)
.delete_oldest_messages()
.finalize();
I change this part of code into this:
auto createOpts = mqtt::create_options_builder()
// .send_while_disconnected(true, true)
.max_buffered_messages(MAX_BUFFERED_MESSAGES)
.delete_oldest_messages()
.finalize();
Then I compile and execute this code, still can not receive message on server side.
This is part of code from "async_publish.cpp"
cout << "\nConnecting..." << endl;
mqtt::token_ptr conntok = client.connect(connOpts);
cout << "Waiting for the connection..." << endl;
conntok->wait();
cout << " ...OK" << endl;
and this is part of code from ”async_publish_time.cpp“:
cout << "Starting connection..." << endl;
cli.connect(connOpts);
auto top = mqtt::topic(cli, "data/time", QOS);
cout << "Publishing data..." << endl;
What's the difference? It is "->wait()"!!!! right!
After I corrected the ”async_publish_time.cpp“ into this:
cout << "Starting connection..." << endl;
cli.connect(connOpts)->wait();
auto top = mqtt::topic(cli, "data/time", QOS);
cout << "Publishing data..." << endl;
Then, I can publish data/time properly!
The text was updated successfully, but these errors were encountered: