Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial handshaking #150

Open
LaudixGit opened this issue Feb 11, 2022 · 1 comment
Open

Initial handshaking #150

LaudixGit opened this issue Feb 11, 2022 · 1 comment

Comments

@LaudixGit
Copy link

Describe Your Goal
Consider the websocket chat example.
When a client connects I want/need to send an initial update/json to populate the browser with the current parameters/settings.
However, when I add any 'send' calls in the 'create' method the device restarts with :
Guru Meditation Error: Core 1 panic'ed (LoadProhibited). Exception was unhandled.

What Does Your Project Look Like

Adding just a single line to the chat example causes the issue:

WebsocketHandler * ChatHandler::create() {
Serial.println("Creating new chat client!");
ChatHandler * handler = new ChatHandler();
for(int i = 0; i < MAX_CLIENTS; i++) {
if (activeClients[i] == nullptr) {
activeClients[i] = handler;
break;
}
}

handler->send("welcome", SEND_TYPE_TEXT);

return handler;
}

ESP32 Module
WT32-ETH01

Software (please complete the following information if applicable)

  • IDE and Version: Arduino 1.8.15

Additional context
What is the correct way to send to a client just after its creation?

@LaudixGit
Copy link
Author

FYI A workaround was to have the client, immediately after establishing a connection to the host, request an update.
And in the message handler function on the server send the current parameters back to the client.

This is not as direct as having the server push the data, but it is adequate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant