I want to connect a NodeMCU Lua socket client to node.js socket.io server.
NodeMCU Lua code:
sk = net.createConnection(net.TCP, 0)
sk:on("receive", function ( sck,c )
print (c)
end)
sk:on("connection", function ( sck,c )
print("Connected")
sk:send("Helloooo...")
end)
sk:connect(12346,"192.168.1.100")
Node.js server code:
var express = require('express');
var app = express();
var server = require('http').Server(app);
var io = require('socket.io')(server);
io.on('connection', function(socket){
console.log('someone is connected');
});
server.listen(12346);
The problem:
The on connection event in the Lua client is fired and prints "Connected", but the on connection event in node.js socket.io server isn't fired. I tried the Lua client with a Python socket server and it worked well! And I also tried a node.js socket server with a Javascript socket client and it worked well!
Are there compatibility problems between NodeMCU and socket.io?