BitBotFactory / MikaLendingBot

Automated lending on Cryptocurrency exchanges Poloniex and Bitfinex
http://poloniexlendingbot.readthedocs.io/en/latest/index.html
MIT License
1.11k stars 344 forks source link

Webserver does not show any output #207

Closed Litvakas closed 7 years ago

Litvakas commented 7 years ago

Hello everyone,

Firstly want to say thanks for the developer! And then i want to know what i am doing wrong. It seems that bot does not give any output on my webserver, i can only see blank screen. I am attaching screen shot and my log with configuration. Moreover my LAMP is on raspberry pi 3 model B.

Most recent call back in console.

2017-01-31 01:27:54
Traceback (most recent call last):
  File "lendingbot.py", line 88, in <module>
    Data.update_conversion_rates(output_currency, json_output_enabled)
  File "/var/www/html/poloniexlendingbot-master/poloniexlendingbot-master/modules/Data.py", line 74, in update_conversion_rates
    total_lended = get_total_lended()[0]
  File "/var/www/html/poloniexlendingbot-master/poloniexlendingbot-master/modules/Data.py", line 41, in get_total_lended
    crypto_lended = api.return_active_loans()
  File "/var/www/html/poloniexlendingbot-master/poloniexlendingbot-master/modules/Poloniex.py", line 129, in return_active_loans
    return self.api_query('returnActiveLoans')
  File "/var/www/html/poloniexlendingbot-master/poloniexlendingbot-master/modules/Poloniex.py", line 72, in api_query
    sign = hmac.new(self.Secret, post_data, hashlib.sha512).hexdigest()
  File "/usr/lib/python2.7/hmac.py", line 136, in new
    return HMAC(key, msg, digestmod)
  File "/usr/lib/python2.7/hmac.py", line 71, in __init__
    if len(key) > blocksize:
TypeError: object of type 'NoneType' has no len() 

Configuration file:

#Syntax: ["COIN:mindailyrate:maxactiveamount:maxtolend:maxpercenttolend:maxtole$
#If maxactive amount is 0: stop lending this coin. in the future you'll be able$
#If maxtolend is 0: check for maxpercenttolend.
#If maxpercenttolend is 0: 100% is going to be lend.
#If maxtolendrate is set to more than 0: the maxtolend or maxpercenttolend will$
#coinconfig = ["BTC:0.18:1:0:0:0","CLAM:0.6:1:0:0:0"]

#This option creates a json log file instead of console output which includes t$
#Uncomment both jsonfile and jsonlogsize to enable.
#Keep this in the default location if you want to use the webserver.
jsonfile = www/botlog.json

#Limits the amount of log lines to save.
jsonlogsize = 200

#Enables a webserver for the www folder, in order to easily use the lendingbot.$
startWebServer = true

#Customize the IP and port that the webserver is hosted on. Defaults to 0.0.0.0$
#0.0.0.0 will point to your default IP (Local IP on LAN as well as localhost), $
#Do not set to a reserved port
#Advanced users only.
customWebServerAddress = 192.168.0.17:8080

#The currency that the HTML Overview will present the earnings summary in.
#Options are BTC, USDT, ETH or anything as long as it has a direct BTC market. $
outputCurrency = BTC

I am accessing webserver through this link: http://192.168.0.17/poloniexlendingbot-master/poloniexlendingbot-master/www/lendingbot.html

screen shot 2017-01-31 at 18 42 40

This is json log

{"last_status": "", "last_update": "2017-01-31 01:43:55", "log": ["2017-01-31 01:26:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:27:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:28:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:29:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:30:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:31:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:32:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:33:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:34:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:35:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:36:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:37:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:38:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:39:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:40:54 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:41:55 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:42:55 ERROR: object of type 'NoneType' has no len()", "2017-01-31 01:43:55 ERROR: object of type 'NoneType' has no len()"], "outputCurrency": {}, "raw_data": {}}

Any ideas? Thank you for all the help

Evanito commented 7 years ago

The webpage expects the .json log to be in the root directory. You are very strangely hosting the entire folder tree with LAMP so while it is looking for http://192.168.0.17/botlog.json it needs to look for http://192.168.0.17/poloniexlendingbot-master/poloniexlendingbot-master/www/botlog.json

You can fix this by:

And as for your error, I believe that is also the result of your setup, as I am unable to reproduce.

rnevet commented 7 years ago

I think you are running 2 webservers, basically the apache webserver (LAMP) and the bot webserver... you should disable one of them (the one you don't need).

As for the other error it looks like somehow the bot is trying to make a call without providing the apikey/secret (which shouldn't be possible). please make sure that you provided the apikey/secret in the config file correctly without any weird characters around them. Also make sure you're on the most recent master revision.

Litvakas commented 7 years ago

Thank you guys for your help!

@Evanito i did as you said and re-organized the files a bit. Mainly i have transfered all the files to 1 folder and changed the default.cfg line www/botlog.json to botlog.json. Everything seems to be working okey now.

@rnevet To be honest i am a bit new to LAMP and i am still on my learning curve. I have installed this bot on var/www/html folder which i believe is for my localhost - default webserver.

Do i understand correctly poloniexlending bot has its own independent webservice, in my case i just need to open the 8080 port and i could launch it from anywhere? Or i need to make any changes in apache2 folder and apache config files, to assign a different file path for this both?

Now i am accessing the bot on http://192.168.0.17/lendingbot.html And files are located in var/www/html/(all poloniex bot files in 1 folder)

About the error - i think the issues is that i have renamed somewhere in the code one line, after i have re-installed the bot - error dissapeared.

Apologies if my questions are to obvious or at the beginners level, but i am keen on learning how this should work correctly. :)

Thank you,

rnevet commented 7 years ago

startWebServer = true - this starts the internal bot webserver, I would suggest you try setting this to false and see if it still works.

Basically all you need in the "var/www/html/" are the html and JSON file... Having the config file there means it is readable and someone can read your API access keys.

Move the bot to another location recommend under "/opt/". Use config option jsonfile to output to "/var/www/html/botlog.json". Place the bot html file also under "/var/www/html/"

You can also use symlink for connecting between the www folder under the bot new location to a folder under "var/www/html/"