RangeError nodejs socket.io
RangeError nodejs socket.io
我得到以下错误
RangeError: Maximum call stack size exceeded
at TCP.hasOwnProperty (native)
at _hasBinary (/usr/local/lib/node_modules/socket.io/node_modules/has-binary/index.js:49:45)
app.js
var express = require('express');
var app = express();
// var responseHandlerRouter = require('./routes/responseHandlerRouter.js');
routes = require('./routes');
var server = app.listen(3000, function () {
console.log('Example app listening on port 3000!');
});
io = require('/usr/local/lib/node_modules/socket.io').listen(server);
app.use('/', routes(io));
route.js
var express = require('express');
var router = express.Router();
module.exports = function (io) {
// all of this router's configurations
router.post('/paymentResponse', function (req, res, next) {
io.sockets.emit('notification', res);
res.end('well finally I am here');
});
return router;
}
index.html
<!doctype html>
<html>
<head>
<script src="http://127.0.0.1:3000/socket.io/socket.io.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.0.0-beta1/jquery.js"></script>
<script>
var socket = io.connect('http://localhost:3000');
socket.on('notification', function (data) {
console.log(data);
});
</script>
</head>
<body>
<ul id='messages'></ul>
</body>
</html>
当我发布到URL时http://localhost:3000/paymentResponse,我在运行nodejs服务器的终端中收到了这个错误。
您正在序列化整个响应对象(res
参数),这可能会由于循环引用而导致堆栈溢出。不要序列化整个响应对象,而是仔细挑选所需的属性。
相关文章:
- 如何使用Socket.io将命令从客户端发送到服务器
- Socket.io socket.emit 不将数据传递到服务器
- Socket.IO socket.id 更改同一客户端而不重新连接
- Node.js+Express+socket.io-socket.io服务不正常
- 节点.js /socket.io/socket.io.js 找不到
- 发出到套接字 IO socket.id
- 将socket.io/socket.io.js加载到html头中返回"ReferenceError:io未定义
- 错误连接拒绝http://localhost:3000/socket.io/socket.io.js.
- Sails.js IO.socket not firing
- 使用AJAX与套接字.IO socket消息
- Socket.io socket.disconnect();
- 正在检索io.socket中的所有套接字对象
- Socket IO - Socket.Emit被发送到所有客户端
- Express.js 'socket.io/socket.io.js 404'
- 使用公共IP运行/socket.io/socket.io.js
- socket.io/socket.io.js stuck on (pending) - Node.js
- 我得到了GEThttp://localhost:81/socket.io/socket.io.jsnet::ERR_CO
- Node.js /socket.io/socket.io.js not found express 4.0
- 带io.socket的sails应用程序
- Express -如何在路由文件中使用io.socket.emit