jack3898 / discord-youtube-bot-2

A powerful Discord YouTube Bot.
0 stars 0 forks source link

Can't get the bot running #6

Closed vparys closed 2 years ago

vparys commented 2 years ago

Hello, recently I came across this interesting project but I am not able to get it going. I've configured .env according to readme but I'm still stuck at the same error. I'm probably missing some basic step but I haven't been able to find anything online.

image

Debian 11

jack3898 commented 2 years ago

Can you give me some information on what steps you took to set up the bot? 🙂

Jack

vparys commented 2 years ago

I've installed npm, git and docker on fresh debian server, cloned this repo, renamed .env-example to .env and pasted inside Application ID into CLIENT_ID, Token into DISCORD_TOKEN and the google api token into GOOGLE_API_TOKEN. Then I've built the docker container and since then I'm getting this error. It seems to me, that the problem is with sending the HTTP request because the same error occurs even after I've for example deleted .env.

jack3898 commented 2 years ago

It seems the code is failing to connect to Redis. Your setup procedure doesn't give me any red flags... though you shouldn't need to install npm on the host machine as npm will be bundled in as part of the Docker! 🙂

Did you run docker-compose up in the root of the project's directory?

vparys commented 2 years ago

Yes, I did :/

jack3898 commented 2 years ago

It seems I have been able to reproduce your problem:

image

It was caused by me running the bot container by itself. This is not a bug, and entirely expected!

I am confident if you install/run that docker-compose command it will work.

The reason this is, is because when you run docker-compose, you're actually linking two containers together as services. One runs Node.js and npm, and the other runs Redis. When they run together, the two containers have their own internal network where the bot can privately communicate with the Redis container. But without docker-compose, and the bot being by itself, the connection to Redis cannot be established.

jack3898 commented 2 years ago

Hmmm, just seen your reply after saying you used docker-compose. I will have another think about this and get back to you.

jack3898 commented 2 years ago

What's the REDIS_HOST value set to in .env? If it's not set to redis that could also cause this issue.

vparys commented 2 years ago

Yes, it is set to redis and I've been using docker-compose :(. I've also tried reinstalling whole debian just in case. image

jack3898 commented 2 years ago

Can you please pull the latest code with git pull and run docker-compose up --build and then send me a screenshot of the bit where it says "Redis host: ..."?

vparys commented 2 years ago

Here you go image

jack3898 commented 2 years ago

I must say, I have spun up a new Debian 11 server and I am baffled because it also does not seem to work for me either! On my Windows Docker installation it's fine, but on Debian it is not. Still very unsure why.

vparys commented 2 years ago

And have you already tried other distributions?

jack3898 commented 2 years ago

I haven't yet, no. But I will do later!

m0s-s commented 2 years ago

image same problem found on ubuntu 20.04 clean installation

jack3898 commented 2 years ago

I would like to thank whoever submitted a question to StackOverflow!!

https://stackoverflow.com/questions/70746842/connection-timeout-http-put-request

Found it whilst trying to fix it myself! I am still just as stumped about the problem and am still working on it.

EDIT: Just realised vparys is here, it's not easy to remember names. 😅

jack3898 commented 2 years ago

Hi guys I have found the reason why and I am going to issue a patch tonight!

What was the problem?

In src/classes/modules/Cache.ts and src/classes/modules/QueueManager.ts I declare a static property that holds the Redis client. HOWEVER, as I have learned tonight having more than one Redis client does not work and is most likely, from my empirical observations bad practice.

It just so happens that Windows is fine with it, but Linux does not like it at all. You learn something new every day.

Not a bug with Docker or Docker compose! Just a little bit of shabby code. 😂

vparys commented 2 years ago

That's awesome!

I also hope it didn't make you mad that I've submitted this problem on stackoverflow, just wanted to save you some time! 😄

jack3898 commented 2 years ago

That's awesome!

I also hope it didn't make you mad that I've submitted this problem on stackoverflow, just wanted to save you some time! 😄

Not a problem at all! StackOverflow can be... well... hostile at times. So if anything you were the punching bag for any keyboard nerds 😂 And I appreciate that.

jack3898 commented 2 years ago

This issue is now resolved at commit a7857dd6ec924ff7fb37ba40a74b34d85dd622d3

Thanks for the help to all involved!