简体   繁体   English

我正在获取GET http:// localhost:81 / socket.io / socket.io.js net :: ERR_CONNECTION_REFUSED

[英]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.

相关问题 ERR_CONNECTION_REFUSED http://localhost:3000/socket.io/socket.io.js - ERR_CONNECTION_REFUSED http://localhost:3000/socket.io/socket.io.js Socket.IO ERR_CONNECTION_REFUSED - Socket.IO ERR_CONNECTION_REFUSED polling-xhr.js:229 GET http://localhost:3000/socket.io/?EIO=4&transport=polling&t=NMtL4rR.net::ERR_CONNECTION_REFUSED - polling-xhr.js:229 GET http://localhost:3000/socket.io/?EIO=4&transport=polling&t=NMtL4rR net::ERR_CONNECTION_REFUSED Heroku Node.js + Socket.io:部署到Heroku后,我得到一个ERR_CONNECTION_REFUSED - Heroku Node.js + Socket.io: After deploying to Heroku, I get a ERR_CONNECTION_REFUSED Node.js + Apache-https:// localhost:3000 / socket.io / ERR_CONNECTION_REFUSED - Node.js + Apache - https://localhost:3000/socket.io/ ERR_CONNECTION_REFUSED 从socket.io获取404(找不到文件)和net :: ERR_CONNECTION_REFUSED - GET 404 (File not found) and net::ERR_CONNECTION_REFUSED from socket.io Node.js服务器上带有socket.io的ERR_CONNECTION_REFUSED - ERR_CONNECTION_REFUSED with socket.io on Node.js server 套接字io客户端网:: ERR_CONNECTION_REFUSED - socket io client net::ERR_CONNECTION_REFUSED 加载反应应用程序错误时,polling-xhr.js:203 GET https://localhost:8001/socket.io/?EIO=4&amp;transport=polling&amp;t=NZJdzB8 net::ERR_CONNECTION_REFUSED - while loading react app error , polling-xhr.js:203 GET https://localhost:8001/socket.io/?EIO=4&transport=polling&t=NZJdzB8 net::ERR_CONNECTION_REFUSED Socket.io http://localhost:3000/socket.io/socket.io.js 404 (Not Found) - 如何配置socket.IO - nodejs, apache2, websockets - Socket.io http://localhost:3000/socket.io/socket.io.js 404 (Not Found) - How to configure socket.IO - nodejs, apache2, websockets
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM