Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

GET/ socket io not found 404 #1

Open
@BilelAyech

Description

I need your help after I upgrade the dependencies to "socket.io": "^4.6.1" ...I am getting an error in the console of the browser : GET http://127.0.0.1:5500/socket.io/?EIO=4&transport=polling&t=OVI3WYK 404 (Not Found)
below is my code

my server:

var http = require('http');
var fs = require('fs');
var index = fs.readFileSync( 'index.html');
const { SerialPort } = require('serialport')
const { ReadlineParser } = require('@serialport/parser-readline')
const parser = new ReadlineParser({ delimiter: '\r\n' });
var port = new SerialPort(
 { path: 'COM3', baudRate: 9600 , dataBits: 8, parity: 'none', stopBits: 1, flowControl: false}
 );
port.pipe(parser);
var app = http.createServer(function(req, res) {
 res.writeHead(200, {'Content-Type': 'text/html'});
 res.end(index);
});
var io = require('socket.io')(app);
io.on('connection', function(socket) {
 
 socket.on('lights',function(data){
 
 console.log( data );
 
 port.write( data.status );
 
 });
 
});
app.listen(5500);

my index.html:

<!doctype html>
<html>
 <head>
 <title>Communicating from Node.js to an Arduino</title>
 <script src="https://cdn.socket.io/4.6.1/socket.io.min.js"></script>
 </head>
 <body>
 <h1>Communicating from Node.js to an Arduino</h1>
 <button id="lightOn">Turn Light On</button>
 <button id="lightOff">Turn Light Off</button>
 <script>
 
 var socket = io();
 document.getElementById('lightOn').onclick = function() {
 
 socket.emit('lights', { "status":"1" });
 
 };
 
 document.getElementById('lightOff').onclick = function(){
 
 socket.emit('lights', { "status":"0" });
 
 };
 
 </script>
 
 </body>
</html>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

        AltStyle によって変換されたページ (->オリジナル) /