numtel / meteor-mysql

Reactive MySQL for Meteor
MIT License
343 stars 41 forks source link

ECONNREFUSED/ENOENT after deploy #63

Open HamburgerJungeJr opened 8 years ago

HamburgerJungeJr commented 8 years ago

Hi,

i try to connect to a mysql database on an ubuntu server. I've deployed my application with meteor-up. The application is running but i cannot conenct to my mysql database.

If I use host/port I got the Error

{ [Error: connect ECONNREFUSED]
  code: 'ECONNREFUSED',
  errno: 'ECONNREFUSED',
  syscall: 'connect',
  fatal: true }
Exception from sub termineDetail id nSMvTBC3ihCw6jk2h Error: Cannot enqueue Query after fatal error.
    at Object.Future.wait (/bundle/bundle/programs/server/node_modules/fibers/future.js:398:15)
    at LiveMysqlSelect.LiveMysql.LiveMysqlSelect._publishCursor (packages/numtel_mysql/packages/numtel_mysql.js:55:1)
    at [object Object]._.extend._publishHandlerResult (livedata_server.js:1065:13)
    at [object Object]._.extend._runHandler (livedata_server.js:1038:10)
    at [object Object]._.extend._startSubscription (livedata_server.js:842:9)
    at [object Object]._.extend.protocol_handlers.sub (livedata_server.js:614:12)
    at livedata_server.js:548:43
    - - - - -
    at Protocol._validateEnqueue (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql/lib/protocol/Protocol.js:194:16)
    at Protocol._enqueue (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql/lib/protocol/Protocol.js:129:13)
    at Connection.query (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql/lib/Connection.js:201:25)
    at update (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql-live-select/lib/QueryCache.js:72:18)
    at QueryCache.invalidate (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql-live-select/lib/QueryCache.js:119:5)
    at new LiveMysqlSelect (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql-live-select/lib/LiveMysqlSelect.js:46:16)
    at LiveMysql.select (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql-live-select/lib/LiveMysql.js:100:19)
    at [object Object]._handler (server/database.js:32:21)
    at maybeAuditArgumentChecks (livedata_server.js:1698:12)
    at [object Object]._.extend._runHandler (livedata_server.js:1023:17)
    at [object Object]._.extend._startSubscription (livedata_server.js:842:9)
    at [object Object]._.extend.protocol_handlers.sub (livedata_server.js:614:12)
    at livedata_server.js:548:43

If I connect with socket I got the error

{ [Error: connect ENOENT]
  code: 'ENOENT',
  errno: 'ENOENT',
  syscall: 'connect',
  fatal: true }
Exception from sub termineDetail id yb6Kh8GypDtqfgmc9 Error: Cannot enqueue Query after fatal error.
    at Object.Future.wait (/bundle/bundle/programs/server/node_modules/fibers/future.js:398:15)
    at LiveMysqlSelect.LiveMysql.LiveMysqlSelect._publishCursor (packages/numtel_mysql/packages/numtel_mysql.js:55:1)
    at [object Object]._.extend._publishHandlerResult (livedata_server.js:1065:13)
    at [object Object]._.extend._runHandler (livedata_server.js:1038:10)
    at [object Object]._.extend._startSubscription (livedata_server.js:842:9)
    at [object Object]._.extend.protocol_handlers.sub (livedata_server.js:614:12)
    at livedata_server.js:548:43
    - - - - -
    at Protocol._validateEnqueue (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql/lib/protocol/Protocol.js:194:16)
    at Protocol._enqueue (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql/lib/protocol/Protocol.js:129:13)
    at Connection.query (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql/lib/Connection.js:201:25)
    at update (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql-live-select/lib/QueryCache.js:72:18)
    at QueryCache.invalidate (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql-live-select/lib/QueryCache.js:119:5)
    at new LiveMysqlSelect (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql-live-select/lib/LiveMysqlSelect.js:46:16)
    at LiveMysql.select (/bundle/bundle/programs/server/npm/numtel_mysql/node_modules/mysql-live-select/lib/LiveMysql.js:100:19)
    at [object Object]._handler (server/database.js:33:21)
    at maybeAuditArgumentChecks (livedata_server.js:1698:12)
    at [object Object]._.extend._runHandler (livedata_server.js:1023:17)
    at [object Object]._.extend._startSubscription (livedata_server.js:842:9)
    at [object Object]._.extend.protocol_handlers.sub (livedata_server.js:614:12)
    at livedata_server.js:548:43

Where is the problem?? Thanks for help.

anilkhichar commented 8 years ago

Can you please put your connection detail like settings.json and the code that is using it?

HamburgerJungeJr commented 8 years ago

Thanks. Is this the code you mean?

Meteor.startup(function(){
  // Connection zur MySQL-DB
  var database = new LiveMysql({
    host: 'localhost',
    port: "3306",
    user: 'root',
    password: 'myrootpassword',
    database: 'ackellinghusen'
  });
  // News publisher
  Meteor.publish('news', function () {
    return database.select("SELECT * FROM tx_news_domain_model_news WHERE deleted=0 AND pid=96 ORDER BY datetime DESC", [{table: "tx_news_domain_model_news"}]);
  });

  // News-tag publisher
  Meteor.publish('newsTags', function () {
    return database.select("SELECT mm.*, tag.* FROM tx_news_domain_model_news_tag_mm as mm JOIN tx_news_domain_model_tag as tag on mm.uid_foreign=tag.uid", [{table: "tx_news_domain_model_news_tag_mm"}, {table: "tx_news_domain_model_tag"}]);
  });

  // News-tag publisher
  Meteor.publish('newsImages', function () {
    return database.select("SELECT file.identifier AS path, ref.uid_foreign AS newsId, ref.sorting_foreign AS sorting, ref.showinpreview AS isPreview FROM sys_file AS file JOIN sys_file_reference AS ref ON file.uid=ref.uid_local WHERE ref.pid=96;", [{table: "sys_file"}, {table: "sys_file_reference"}]);
  });

  // Termine publisher
  Meteor.publish('termine', function () {
    return database.select("SELECT uid, unix_timestamp(start_date) AS start_date, unix_timestamp(sec_to_time(start_time)) as start_time, title FROM tx_cal_event WHERE calendar_id=1 AND date(start_date) >= Date(now()) AND deleted=0 ORDER BY start_date ASC;", [{table:"tx_cal_event"}]);
  });

  //TerminDetail publisher
  Meteor.publish('termineDetail', function () {
    return database.select("SELECT event.uid, unix_timestamp(event.start_date) as start_date, unix_timestamp(event.end_date) as end_date, event.allday, unix_timestamp(sec_to_time(event.start_time)) as start_time, unix_timestamp(sec_to_time(event.end_time)) as end_time,event.title, event.description, organizer.name AS organizerName, location.name AS locationName, location.street AS locationStreet, location.zip as locationZip, location.city AS locationCity, location.latitude AS locationLatitude, location.longitude AS locationLongitude FROM tx_cal_event AS event LEFT JOIN tx_cal_organizer AS organizer ON event.organizer_id=organizer.uid LEFT JOIN tx_cal_location AS location ON event.location_id=location.uid;", [{table: "tx_cal_event"},{table: "tx_cal_organizer"},{table: "tx_cal_location"}]);
  });
});

I forgot to mention, that evrything works on my dev-machine. With port and with socket.

anilkhichar commented 8 years ago

What's your mysql version on production & dev? Is the bin log enabled on prod same way as dev ?

anilkhichar commented 8 years ago

As per my past experience it could be due to mysql version.

HamburgerJungeJr commented 8 years ago

Dev

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
[mysqld]
 log-bin=mysql-bin
 expire_logs_days = 2
server-id        = 1
binlog_format    = row

Prod

!includedir /etc/mysql/conf.d/
!includedir /etc/mysql/mysql.conf.d/
# binlog config
[mysqld]
 log-bin=mysql-bin
 expire_logs_days = 2
server-id        = 1
binlog_format    = row
#bind-address = 0.0.0.0
anilkhichar commented 8 years ago

Please try the below amendments and let me know if still experiencing the same error: Application: var database = new LiveMysql({ host: 'localhost', port: "3306", user: 'root', password: 'myrootpassword', database: 'ackellinghusen', "serverId": 1, "minInterval": 200 });

my.cnf: log_bin = /var/log/mysql/mysql-bin.log expire_logs_days = 2 server_id = 1 binlog_format = row binlog_do_db = ackellinghusen max_binlog_size = 100M

Now restart your mysql server and you will be good with your binlog enabling. Thne restart meteor application server and you should be good.

HamburgerJungeJr commented 8 years ago

Thanks, but nothing changed

HamburgerJungeJr commented 8 years ago

I've got the problem.

Everything works when I change localhost to the IP of my Server. But where does this come from??

SantoshSrinivas79 commented 8 years ago

@HamburgerJungeJr Did you use mupx to deploy or something else? My rather simple app is working on dev, but when I use mupx deploy, I am getting a ECONNREFUSED error