I’m trying to setup a websocket between an ESP32-S3 board and a web navigator (Firefox)
My firware has a web server, websocket server and also embeed a web client written in html, css, js, based on esp-idf.
My web client is placed in a js file
function startWebSocketConnection() {
socket = new WebSocket("ws://192.168.4.1/ws");
In this configuration, the client fails to open a connection to the websocket server.
But, when placed inside the html file it works
<script type="text/javascript">
var socket = new WebSocket("ws://192.168.4.1/ws");
socket.onopen = function () {
socket.send("Hello Server!");
};
Does someone have an idea why ? How can it be solved ?
Thanks in advance for your help,
Fabrice, F4BJH
try to connect to my websocket. does not open connection if javascript code is not placed in the html part
F4BJH is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.