如何在node.js服务器中调试socket.io的模拟浏览器客户端
我在node.js 服务器中模拟了socket.io 的浏览器客户端,
当特定消息从真实浏览器客户端到达时,我正在创建模拟的浏览器客户端。
console.log('creating client of '+sessionId);
var socket=client.init();
console.log(socket);
这是我在 node.js 中的模拟浏览器客户端,我正在使用 https://github.com /saschagehlich/node-socket.io-client 用于创建客户端。
exports.init=function(){
var socket = new io.Socket(config.host, {port: config.port, rememberTransport: false});
// when connected, clear out display
socket.on('connect',function() {
console.log('dummy user connected');
});
socket.on('disconnect',function() {
console.log('disconnected dummy');
});
socket.on('message', function(data){
console.log(data);
});
socket.connect();
return socket;
};
问题是客户端中的控制台没有被打印,套接字被返回并打印。但不是控制台。在客户端代码中。 我还想要模拟客户端的会话ID,我怎样才能得到它?
I have simulated a browser client of socket.io in the node.js server
I am creating the simulated browser client when particular message arrived from a Real browser client.
console.log('creating client of '+sessionId);
var socket=client.init();
console.log(socket);
here is my Simulated browser client in node.js , I am using https://github.com/saschagehlich/node-socket.io-client for creating client.
exports.init=function(){
var socket = new io.Socket(config.host, {port: config.port, rememberTransport: false});
// when connected, clear out display
socket.on('connect',function() {
console.log('dummy user connected');
});
socket.on('disconnect',function() {
console.log('disconnected dummy');
});
socket.on('message', function(data){
console.log(data);
});
socket.connect();
return socket;
};
The problem is this that the consoles in the client is not getting printed , the socket is return and printed . but not console. in client code.
And i also want the session id of simulated client , how can i get it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Node.js 有一个简单的调试器,可以使用以下命令调用:
node debug script.js
该调试器具有简单的命令,例如
print
或step
。您可以内联编写代码并使用 util.inspect() 来检查对象。更高级的方法是使用 Google 的 V8 调试器 http://code.google.com/p/ v8/wiki/调试器协议
但这通常是一种矫枉过正...
Node.js has a simple debugger that can be invoked using:
node debug script.js
The debugger has simple commands like
print
orstep
. You could write code inline and useutil.inspect()
for inspecting objects.Something more advanced would be using Google's V8 debugger http://code.google.com/p/v8/wiki/DebuggerProtocol
but that's usually an overkill...