1

我正在为一个简单的聊天应用程序使用以下代码https://gist.github.com/2031681 。

我跑node chat-server.js得到

Tue Jan 08 2013 15:45:52 GMT+0200 (IST) Server is listening on port 1337

我尝试通过访问它http://localhost:1337/chat.html并获得以下信息

No data received
Error 324 (net::ERR_EMPTY_RESPONSE): The server closed the connection without sending any data.

我是 node.js 的新手,我不知道这个问题可能来自哪里

4

2 回答 2

1

I have also tried this tutorial and faced the same problem. But i have found issues and fixed it.

You have to run chat.html as a file by simply double clicking the file you dont need to access it via localhost. Also change

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>

to

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>

it will work. If you want it to be accessible on other computers on your network put it in wamp/www folder or htdocs folder in xampp and change the following line in frontend.js file:

var connection = new WebSocket('ws://127.0.0.1:1337');

into

var connection = new WebSocket('ws://your_pc_ip:1337');
于 2013-02-27T07:19:33.150 回答
0

搜索了几个小时可能会出现非常类似的问题时,突然我们发现带有我们的 API 和 Web 服务的服务器已关闭。该应用程序在本地主机上运行,​​但对服务器的 API 调用不返回任何内容哈哈 :(

于 2013-02-27T13:50:31.457 回答