i'm implementing a web socket in nodejs to make a query to dynamodb but appear this error: buffer.js:398 Buffer.isBuffer = function isBuffer(b) { ^
RangeError: Maximum call stack size exceeded
at Function.isBuffer (buffer.js:398:36)
at hasBinary (E:\ProyectoSMET\Aprendiendo_nodejs_y_Angular\angular-socket-io-example-master\server\node_modules\has-binary2\index.js:44:66)
at hasBinary (E:\ProyectoSMET\Aprendiendo_nodejs_y_Angular\angular-socket-io-example-master\server\node_modules\has-binary2\index.js:58:59)
at hasBinary (E:\ProyectoSMET\Aprendiendo_nodejs_y_Angular\angular-socket-io-example-master\server\node_modules\has-binary2\index.js:58:59)
at hasBinary (E:\ProyectoSMET\Aprendiendo_nodejs_y_Angular\angular-socket-io-example-master\server\node_modules\has-binary2\index.js:58:59)
at hasBinary (E:\ProyectoSMET\Aprendiendo_nodejs_y_Angular\angular-socket-io-example-master\server\node_modules\has-binary2\index.js:58:59)
at hasBinary (E:\ProyectoSMET\Aprendiendo_nodejs_y_Angular\angular-socket-io-example-master\server\node_modules\has-binary2\index.js:58:59)
at hasBinary (E:\ProyectoSMET\Aprendiendo_nodejs_y_Angular\angular-socket-io-example-master\server\node_modules\has-binary2\index.js:58:59)
at hasBinary (E:\ProyectoSMET\Aprendiendo_nodejs_y_Angular\angular-socket-io-example-master\server\node_modules\has-binary2\index.js:58:59)
at hasBinary (E:\ProyectoSMET\Aprendiendo_nodejs_y_Angular\angular-socket-io-example-master\server\node_modules\has-binary2\index.js:58:59)
.....here is my code:
let app = require('express')();
let http = require('http').Server(app);
let io = require('socket.io')(http);
const AWS = require('aws-sdk');
AWS.config.update({ region: 'us-west-2' });
docClient = new AWS.DynamoDB.DocumentClient();
const tableName = 'Dispositivo';
var datos=docClient.scan({
TableName: tableName
},(err, data)=>{
if(err) {
console.log(err);
} else {
console.log(data);
}
});
io.on('connection', (socket) => {
// Log whenever a user connects
console.log('user connected');
// Log whenever a client disconnects from our websocket server
socket.on('disconnect', function(){
console.log('user disconnected');
});
// When we receive a 'message' event from our client, print out
// the contents of that message and then echo it back to our client
// using `io.emit()`
socket.on('message', (message) => {
console.log("Message Received: " + message);
io.emit('message', {type:'new-message', text: datos});
});
});
// Initialize our websocket server on port 5000
http.listen(5000, () => {
console.log('started on port 5000');
});