Page 1 of 1

How to write a websocket server without receive any packet from client after handshake

Posted: Thu Sep 21, 2023 3:21 pm
by aurosoares
I'm writing a websocket server based on the github example "echo websocket"(https://github.com/espressif/esp-idf/tr ... cho_server).

The client always receives packets after sending a message to the server in that implementation, however, is there any way to implement a websocket server that periodically sends some data without needing to receive any messages ?

I want just connecting my client and starting to receive data periodically without sending messages.

Auro.

Re: How to write a websocket server without receive any packet from client after handshake

Posted: Fri Sep 22, 2023 8:25 am
by vinci1989
A websocket is a bidirectional communication. As long as the socket is open you can send data at any time. The example you've linked even does that by using the

Code: Select all

ws_async_send
function.

Re: How to write a websocket server without receive any packet from client after handshake

Posted: Fri Sep 22, 2023 3:14 pm
by aurosoares
Thank you for response.

I changed the implementation to an infinite loop within the websocket's http handler, to keep sending the packets. Like a default tcp server. Its works fine, but during the loop execution, all other http requests that are on my server are not answered.

Is there any way to send packets periodically without blocking new http calls during this process?