I am using ESP8266 web server to control GPIO. My Wi-Fi network give it an IP of ....99:3300
And it works...THEN I decided to use node.js ( I am a beginner ) and here it is
<pre
const http = require('http');
const hostname = '192.168.1.99';
const port = 3300;
const server = http.createServer((req, res) => {
res.statusCode = 200;
res.setHeader('Content-Type', 'text/plain');
res.end('/5/on');
});
server.listen(port, hostname, () => {
console.log(`Server running at http://${hostname}:${port}/`);
});
It does not work...
Error: listen EADDRNOTAVAIL: address not available 192.168.1.99:3300
[90m at Server.setupListenHandle [as _listen2] (net.js:1296:21)[39m
[90m at listenInCluster (net.js:1361:12)[39m
[90m at doListen (net.js:1500:7)[39m
[90m at processTicksAndRejections (internal/process/task_queues.js:85:21)[39m
Emitted 'error' event on Server instance at:
[90m at emitErrorNT (net.js:1340:8)[39m
[90m at processTicksAndRejections (internal/process/task_queues.js:84:21)[39m {
code: [32m'EADDRNOTAVAIL'[39m,
errno: [32m'EADDRNOTAVAIL'[39m,
syscall: [32m'listen'[39m,
address: [32m'192.168.1.99'[39m,
port: [33m3300[39m
}
</pre>
my url request gpio 5 to be on ( /5/on) and it is working on the server created by ESP8266
My guess is node.js is trying to "create" an already created server (created by ESP8266 code), but I do not know how to make node.js connect to ALREADY existing web server