OS Ubuntu 18.4
Scope (runtime)
Hi
I have software client that send realtime data via TCP.And nodjs is TCP server listens to it and write to mysql DB.When try to implement the code I am getting runtime error need help.
net.createServer(function (sock){
// We have a connection - a socket object is assigned to the connection automatically
console.log('CONNECTED: ' + sock.remoteAddress + ':' + sock.remotePort);
// Identify this client
sock.name = sock.remoteAddress + ":" + sock.remotePort ;
var chunk = "";
sock.on('data', function (data) {
console.log('DATA ' + sock.remoteAddress + ': ' + data); // Write the data back to the socket,
the client will receive it as data from the server
chunk += data.toString(); // Add string on the end of the variable 'chunk'
// save log to database
pool.getConnection(function (err, conn) {
if (err) throw err;
conn.query('INSERT INTO `DB` (`Table`) VALUES(?)', [chunk] , function (err, result) {
if (err) throw err;
console.log(error.code);
console.log("Inserted");
});
});
===========runtime error==============
/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/protocol/Parser.js:437
throw err; // Rethrow non-MySQL errors
Error: ER_DATA_TOO_LONG: Data too long for column 'Table' at row 1
at Query.Sequence._packetToError (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/protocol/sequences/Sequence.js:47:14)
at Query.ErrorPacket (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/protocol/sequences/Query.js:77:18)
at Protocol._parsePacket (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/protocol/Parser.js:433:10)
at Parser.write (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/protocol/Parser.js:43:10)
at Protocol.write (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/protocol/Protocol.js:38:16)
at Socket.<anonymous> (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/Connection.js:91:28)
at Socket.<anonymous> (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/Connection.js:525:10)
at Socket.emit (events.js:189:13)
at addChunk (_stream_readable.js:284:12)
--------------------
at Protocol._enqueue (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/protocol/Protocol.js:144:48)
at PoolConnection.query (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/Connection.js:201:25)
at /home/jothi/WorkSpaces/javaScript/Node/TCP/server/tcpmysql.js:36:11
at Handshake.onConnect (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/Pool.js:64:7)
at Handshake.<anonymous> (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/Connection.js:525:10)
at Handshake._callback (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/Connection.js:491:16)
at Handshake.Sequence.end (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/protocol/sequences/Sequence.js:83:24)
at Handshake.Sequence.OkPacket (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/protocol/sequences/Sequence.js:92:8)
at Protocol._parsePacket (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/protocol/Protocol.js:291:23)
at Parser._parsePacket (/home/jothi/WorkSpaces/javaScript/Node/TCP/server/mysql/lib/protocol/Parser.js:433:10)
Node.js v10.15.3
OS Ubuntu 18.4 Scope (runtime) Hi I have software client that send realtime data via TCP.And nodjs is TCP server listens to it and write to mysql DB.When try to implement the code I am getting runtime error need help.
==============================code===================================
===========runtime error==============
================================================================
Please help me