[英]I am getting GET http://localhost:81/socket.io/socket.io.js net::ERR_CONNECTION_REFUSED
I am building a real time chat application .i am using socket.io & node.js This is my sever.js file .. 我正在构建一个实时聊天应用程序。我正在使用socket.io和node.js这是我的sever.js文件..
var socket = io.connect('http://localhost:81');socket.on('connect', function({alert('connection established');});
and my path information is 我的路径信息是
<script src="http://localhost:81/socket.io/socket.io.js"></script>
now when i look into directory i saw the socket.io.js path is node_modules/socket.io/lib/socket.io.js 现在当我查看目录时,我看到socket.io.js路径是node_modules / socket.io / lib / socket.io.js
if i change my path like 如果我改变我的道路
<script src="http://localhost:81/node_modules/socket.io/lib/socket.io.js"></script>
then am getting 404 error. 然后出现404错误。 else iam getting GET http://localhost:81/socket.io/socket.io.js net::ERR_CONNECTION_REFUSED
否则我会得到GET http:// localhost:81 / socket.io / socket.io.js net :: ERR_CONNECTION_REFUSED
Just use it like this: <script src="/socket.io/socket.io.js"></script>
Paths inside of node_modules are not hosted to be available from browser. 就像这样使用它:
<script src="/socket.io/socket.io.js"></script>
node_modules内部的路径无法托管,无法从浏览器获得。
Why not use express app to create the server? 为什么不使用Express App创建服务器? And why not refer to their official documentation: http://socket.io/get-started/chat/
而为什么不参考他们的官方文档: http : //socket.io/get-started/chat/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.