Javascript Windows 8应用程序和nodejs websocket未相互连接

Javascript Windows 8应用程序和nodejs websocket未相互连接,javascript,html,node.js,websocket,windows-applications,Javascript,Html,Node.js,Websocket,Windows Applications,我正在使用windows应用程序并尝试将其连接到节点服务器。 我正在windows应用程序中使用web套接字,并在节点上使用npm中的“websocket”。 我在连接这两个字符串时遇到了问题,看起来好像在连接,但当我尝试通过(简单的hello world字符串)发送信息时,什么都没有发生。 我有一个简单的javascript windows应用程序。 在my default.html中,只有一个简单的按钮: <button onclick="Check()">Check stat

我正在使用windows应用程序并尝试将其连接到节点服务器。
我正在windows应用程序中使用web套接字,并在节点上使用npm中的“websocket”。
我在连接这两个字符串时遇到了问题,看起来好像在连接,但当我尝试通过(简单的hello world字符串)发送信息时,什么都没有发生。
我有一个简单的javascript windows应用程序。
在my default.html中,只有一个简单的按钮:

 <button onclick="Check()">Check status</button>
socket.readyState返回me 1,表示已建立连接,套接字已准备好发送! 我的节点服务器如下所示:

#!/usr/bin/env node
var WebSocketServer = require('websocket').server;
var http = require('http');

var server = http.createServer(function(request, response) {
    console.log((new Date()) + ' Received request for ' + request.url);
    response.writeHead(404);
    response.end();
});
server.listen(8080, function() {
    console.log((new Date()) + ' Server is listening on port 8080');
});

wsServer = new WebSocketServer({
    httpServer: server,

    // You should not use autoAcceptConnections for production
    // applications, as it defeats all standard cross-origin protection
    // facilities built into the protocol and the browser.  You should
    // *always* verify the connection's origin and decide whether or not
    // to accept it.
    autoAcceptConnections: true
});
console.log("Here wsServer");
function originIsAllowed(origin) {
  // put logic here to detect whether the specified origin is allowed.
  return true;
}

wsServer.on('request', function(request) {
    //if (!originIsAllowed(request.origin)) {
     // Make sure we only accept requests from an allowed origin
      //request.reject();
     //  console.log((new Date()) + ' Connection from origin ' + request.origin + ' rejected.');
     //  return;
    //}
    console.log("Here");
    var connection = request.accept('echo-protocol', request.origin);
    console.log((new Date()) + ' Connection accepted.');
    connection.on('message', function(message) {
        if (message.type === 'utf8') {
            console.log('Received Message: ' + message.utf8Data);
            connection.sendUTF(message.utf8Data);
        }

    });
    connection.on('close', function(reasonCode, description) {
        console.log((new Date()) + ' Peer ' + connection.remoteAddress + ' disconnected.');
    });
});
我已经进行了安全检查,因为我只想将消息发送到服务器。 但这并没有发生,我不知道为什么!任何帮助都将不胜感激

编辑-- 我只是想它应该可以发送信息,看看它是否击中服务器,但我只是不确定在windows应用程序的ip是什么!如果我能告诉我的节点服务器发送信息,至少让我知道通道已打开。 你知道如何通过javascript获取windows应用程序的ip吗

#!/usr/bin/env node
var WebSocketServer = require('websocket').server;
var http = require('http');

var server = http.createServer(function(request, response) {
    console.log((new Date()) + ' Received request for ' + request.url);
    response.writeHead(404);
    response.end();
});
server.listen(8080, function() {
    console.log((new Date()) + ' Server is listening on port 8080');
});

wsServer = new WebSocketServer({
    httpServer: server,

    // You should not use autoAcceptConnections for production
    // applications, as it defeats all standard cross-origin protection
    // facilities built into the protocol and the browser.  You should
    // *always* verify the connection's origin and decide whether or not
    // to accept it.
    autoAcceptConnections: true
});
console.log("Here wsServer");
function originIsAllowed(origin) {
  // put logic here to detect whether the specified origin is allowed.
  return true;
}

wsServer.on('request', function(request) {
    //if (!originIsAllowed(request.origin)) {
     // Make sure we only accept requests from an allowed origin
      //request.reject();
     //  console.log((new Date()) + ' Connection from origin ' + request.origin + ' rejected.');
     //  return;
    //}
    console.log("Here");
    var connection = request.accept('echo-protocol', request.origin);
    console.log((new Date()) + ' Connection accepted.');
    connection.on('message', function(message) {
        if (message.type === 'utf8') {
            console.log('Received Message: ' + message.utf8Data);
            connection.sendUTF(message.utf8Data);
        }

    });
    connection.on('close', function(reasonCode, description) {
        console.log((new Date()) + ' Peer ' + connection.remoteAddress + ' disconnected.');
    });
});