2
votes

I am making a discord music bot with python using wavelink. When I started this app for the first time on my computer it works fine, but yesterday I wanted to deploy it to heroku and it wasn't working, so I was trying to run it again, just on my computer, with the same code and now it's not working at all. I think the code is totally the same like for the first time, but everytime I run the bot there is:

WEBSOCKET | Connection Failure:: Cannot connect to host 127.0.0.1:2333 ssl:default [Komputer zdalny odrzucił połączenie sieciowe] Traceback (most recent call last): File "C:\Python\lib\site-packages\aiohttp\connector.py", line 936, in _wrap_create_connection return await self._loop.create_connection(*args, **kwargs) # type: ignore # noqa File "C:\Python\lib\asyncio\base_events.py", line 1021, in create_connection raise exceptions[0] File "C:\Python\lib\asyncio\base_events.py", line 1006, in create_connection sock = await self._connect_sock( File "C:\Python\lib\asyncio\base_events.py", line 920, in _connect_sock await self.sock_connect(sock, address) File "C:\Python\lib\asyncio\proactor_events.py", line 702, in sock_connect return await self._proactor.connect(sock, address) File "C:\Python\lib\asyncio\windows_events.py", line 808, in _poll value = callback(transferred, key, ov) File "C:\Python\lib\asyncio\windows_events.py", line 595, in finish_connect ov.getresult() ConnectionRefusedError: [WinError 1225] Komputer zdalny odrzucił połączenie sieciowe

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:\Python\lib\site-packages\wavelink\websocket.py", line 76, in _connect self._websocket = await self._node.session.ws_connect(uri, headers=self.headers, heartbeat=self._node.heartbeat) File "C:\Python\lib\site-packages\aiohttp\client.py", line 721, in _ws_connect resp = await self.request(method, url, File "C:\Python\lib\site-packages\aiohttp\client.py", line 480, in _request conn = await self._connector.connect( File "C:\Python\lib\site-packages\aiohttp\connector.py", line 523, in connect proto = await self._create_connection(req, traces, timeout) File "C:\Python\lib\site-packages\aiohttp\connector.py", line 858, in _create_connection _, proto = await self._create_direct_connection( File "C:\Python\lib\site-packages\aiohttp\connector.py", line 1004, in _create_direct_connection raise last_exc File "C:\Python\lib\site-packages\aiohttp\connector.py", line 980, in _create_direct_connection transp, proto = await self._wrap_create_connection( File "C:\Python\lib\site-packages\aiohttp\connector.py", line 943, in _wrap_create_connection raise client_error(req.connection_key, exc) from exc aiohttp.client_exceptions.ClientConnectorError: Cannot connect to host 127.0.0.1:2333 ssl:default [Komputer zdalny odrzucił połączenie sieciowe]

I think the problem is with this part of code:

async def start_nodes(self):
        await self.bot.wait_until_ready()

        # Initiate our nodes. For this example we will use one server.
        # Region should be a discord.py guild.region e.g sydney or us_central (Though this is not technically required)
        await self.bot.wavelink.initiate_node(host='127.0.0.1',
                                              port=2333,
                                              rest_uri='http://127.0.0.1:2333',
                                              password='youshallnotpass',
                                              identifier='TEST',
                                              region='europe')

File application.yml looks like that:

server: # REST and WS server
  port: 2333
  address: 0.0.0.0
lavalink:
  server:
    password: "youshallnotpass"
    sources:
      youtube: true
      bandcamp: true
      soundcloud: true
      twitch: true
      vimeo: true
      mixer: true
      http: true
      local: false
    bufferDurationMs: 400
    youtubePlaylistLoadLimit: 6 # Number of pages at 100 each
    playerUpdateInterval: 5 # How frequently to send player updates to clients, in seconds
    youtubeSearchEnabled: true
    soundcloudSearchEnabled: true
    gc-warnings: true
    #ratelimit:
      #ipBlocks: ["1.0.0.0/8", "..."] # list of ip blocks
      #excludedIps: ["...", "..."] # ips which should be explicit excluded from usage by lavalink
      #strategy: "RotateOnBan" # RotateOnBan | LoadBalance | NanoSwitch | RotatingNanoSwitch
      #searchTriggersFail: true # Whether a search 429 should trigger marking the ip as failing
      #retryLimit: -1 # -1 = use default lavaplayer value | 0 = infinity | >0 = retry will happen this numbers times

metrics:
  prometheus:
    enabled: false
    endpoint: /metrics

sentry:
  dsn: ""
  environment: ""
#  tags:
#    some_key: some_value
#    another_key: another_value

logging:
  file:
    max-history: 30
    max-size: 1GB
  path: ./logs/

  level:
    root: INFO
    lavalink: INFO

Do you have any ideas?

SOLUTION: Okay, if you have the same problem as me and you are using Lavalink, you have to start the Lavalink server at first. In my case, I have to type in terminal "java -jar Lavalink.jar" to start the server.

1
Does this answer your question? stackoverflow.com/questions/63347818/…0dminnimda

1 Answers

1
votes

I was facing the same problem but then i figured it out

you need to setup Lavalink

  1. Download OpenJDK 13.0.2 and then extract
  2. Download Lavalink
  3. Paste Lavalink.jar inside bin from the 1st step
mv ./Lavalink.jar ./open-jdk/bin
  1. create a new file application.yml and paste this code
    - make sure to change address: 0.0.0.0 to address: 127.0.0.1
server: # REST and WS server
  port: 2333
  address: 127.0.0.1
lavalink:
  server:
    password: "youshallnotpass"
    sources:
      youtube: true
      bandcamp: true
      soundcloud: true
      twitch: true
      vimeo: true
      http: true
      local: false
    bufferDurationMs: 400
    youtubePlaylistLoadLimit: 6 # Number of pages at 100 each
    playerUpdateInterval: 5 # How frequently to send player updates to clients, in seconds
    youtubeSearchEnabled: true
    soundcloudSearchEnabled: true
    gc-warnings: true
    #ratelimit:
      #ipBlocks: ["1.0.0.0/8", "..."] # list of ip blocks
      #excludedIps: ["...", "..."] # ips which should be explicit excluded from usage by lavalink
      #strategy: "RotateOnBan" # RotateOnBan | LoadBalance | NanoSwitch | RotatingNanoSwitch
      #searchTriggersFail: true # Whether a search 429 should trigger marking the ip as failing
      #retryLimit: -1 # -1 = use default lavaplayer value | 0 = infinity | >0 = retry will happen this numbers times

metrics:
  prometheus:
    enabled: false
    endpoint: /metrics

sentry:
  dsn: ""
  environment: ""
#  tags:
#    some_key: some_value
#    another_key: another_value

logging:
  file:
    max-history: 30
    max-size: 1GB
  path: ./logs/

  level:
    root: INFO
    lavalink: INFO
  1. go to command prompt and execute below command
pip install discord.py[voice] wavelink
  1. open the folder where you extracted JDK and then type
java -jar Lavalink.jar

this will start the lavalink server and then you will be able to use your bot


for more help check out this video