简体   繁体   English

端口3000上的Socket IO econnrefused

[英]Socket IO econnrefused on port 3000

I'm running a node server using socket.io 0.9.16 and after restarting my server recently I got the above mentioned error: 我正在使用socket.io 0.9.16运行节点服务器,最近重新启动服务器后,出现上述错误:

{ [Error: connect ECONNREFUSED]
  stack: 'Error: connect ECONNREFUSED\n    at exports._errnoException (util.js:676:11)\n    at Object.afterConnect [as oncomplete] (net.js:938:19)\n    --------------------\n    at Protocol._enqueue (
/var/www/node_modules/mysql-activerecord/node_modules/mysql/lib/protocol/Protocol.js:110:48)\n    at Protocol.handshake (/var/www/node_modules/mysql-activerecord/node_modules/mysql/lib/protocol/Protoc
ol.js:42:41)\n    at Connection.connect (/var/www/node_modules/mysql-activerecord/node_modules/mysql/lib/Connection.js:98:18)\n    at Connection._implyConnect (/var/www/node_modules/mysql-activerecord
/node_modules/mysql/lib/Connection.js:296:10)\n    at Connection.query (/var/www/node_modules/mysql-activerecord/node_modules/mysql/lib/Connection.js:154:8)\n    at get (/var/www/node_modules/mysql-ac
tiverecord/index.js:387:15)\n    at Manager.<anonymous> (/var/www/mutual.js:101:71)\n    at Manager.authorize (/var/www/node_modules/socket.io/lib/manager.js:910:31)\n    at Manager.handleHandshake (/
var/www/node_modules/socket.io/lib/manager.js:786:8)\n    at Manager.handleRequest (/var/www/node_modules/socket.io/lib/manager.js:593:12)',
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  fatal: true }

nmap localhost returns: nmap localhost返回:

Starting Nmap 5.21 ( http://nmap.org ) at 2014-07-22 21:02 EDT
Nmap scan report for localhost (127.0.0.1)
Host is up (0.0000050s latency).
Hostname localhost resolves to 2 IPs. Only scanned 127.0.0.1
rDNS record for 127.0.0.1: localhost.localdomain
Not shown: 992 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
53/tcp   open  domain
80/tcp   open  http
587/tcp  open  submission
3000/tcp open  ppp
3306/tcp open  mysql
9000/tcp open  cslistener

netstate -an | netstate -an | grep "LISTEN " returns grep“ LISTEN”返回

tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN     
tcp        0      0 0.0.0.0:3000            0.0.0.0:*               LISTEN     
...

iptables --list returns iptables --list返回

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:3000

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination

Relevant server code: 相关服务器代码:

var mysql = require('mysql-activerecord'),
    marked = require('marked'),
    conn = new mysql.Adapter({
            server: 'server-name',
            username: 'user',
            password: 'pass',
            database: 'database'
    }),
    moment = require('moment');

var io = require('socket.io').listen(3000);

Relevant client code: 相关客户代码:

a=io.connect("http://server-name:3000/",{query:stuff})

Thanks in advance for the help. 先谢谢您的帮助。 Let me know if you need anymore information. 让我知道您是否需要更多信息。 Sorry if this post is a bit long. 抱歉,如果这篇文章有点长。

The ECONNREFUSED has nothing to do with socket.io, if you look at the backtrace provided in the error, you can see it's coming from the mysql module. ECONNREFUSED与socket.io无关,如果查看错误中提供的回溯,则可以看到它来自mysql模块。 So it appears that your mysql server is not listening on server-name on port 3306 (or at least something is blocking access to it). 因此,看来您的mysql服务器未在端口3306上的server-name上进行监听(或至少有某些阻止它的访问)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM