ALERT!
Click here to register with a few steps and explore all our cool stuff we have to offer!

Jump to content



Photo

How To Keep Trade Bot Connected to MYSQL


  • Please log in to reply
How To Keep Trade Bot Connected to MYSQL

#1

Atep
Atep
    Offline
    0
    Rep
    -2
    Likes

    Overlord

Posts: 119
Threads: 5
Joined: Nov 15, 2015
Credits: 0

Eight years registered
#1

I know some people might have come across this error before ( I did at least), where the bot would time out from the mysql database. The solution is pretty simple when you think about it.

DjxdPeh.jpg

 

Inside your trade bots script find the mysql connection code or add it as it's needed to connect to the mysql database.

var mysql = require('mysql');
var connection = mysql.createConnection({
	host     : '', // MySQL Host
	user     : '', // MySQL User
	password : '', // MySQL Password
	database : '' // MySQL Databse
});

Finally you want to add this to the bottom of your script so it checks for a connection every 5 seconds. (You can change this to pretty much any code you want that loops the connection or checks for it or w.e. I just know this gets the job done :^.)

setInterval(function () {
	connection.query('SELECT 1');
}, 5000);

Edited by androidphreak, 02 May 2016 - 11:28 PM.

  • 0

#2

RatexIndex
RatexIndex
    Offline
    67
    Rep
    45
    Likes

    Chaos Computer Club

Posts: 287
Threads: 22
Joined: Sep 24, 2015
Credits: 0

Eight years registered
#2

use pm2 and the bot is restarting self ;)

 

Better as nodejs

 

https://www.npmjs.com/package/pm2


  • 1

HHKV5OV.png
1000110 --- 1001100 --- 1001010 --- 0011001 - HIDE YOURSELF - 1001010 --- 0011001 --- 1001101 --- 0111001


#3

Atep
Atep
    Offline
    0
    Rep
    -2
    Likes

    Overlord

Posts: 119
Threads: 5
Joined: Nov 15, 2015
Credits: 0

Eight years registered
#3

use pm2 and the bot is restarting self ;)

 

Better as nodejs

 

https://www.npmjs.com/package/pm2

Looks pretty nice from just an overview and reading about it on there site. I will download it and implement it when I can. Thank you for your contribution to this topic.

edit: Works like a charm on my windows server :^.


Edited by androidphreak, 04 May 2016 - 06:49 AM.

  • 0


 Users browsing this thread: