timeout of 60 seconds to connect to lavalink
This commit is contained in:
parent
82a682f03a
commit
1266b63e75
1 changed files with 6 additions and 1 deletions
|
@ -354,7 +354,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
|
|||
await node.destroy()
|
||||
|
||||
nodes = {'MAIN': {'host': f'{self.url}',
|
||||
'port': 2333,
|
||||
'port': 2334,
|
||||
'rest_uri': f'http://{self.url}:2333',
|
||||
'password': 'youshallnotpass',
|
||||
'identifier': 'MAIN',
|
||||
|
@ -363,6 +363,7 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
|
|||
|
||||
nodeValues = list(nodes.values())
|
||||
n = 0
|
||||
timeout = 60 # en secondes
|
||||
while n < len(nodeValues):
|
||||
location = (nodeValues[n]["host"], nodeValues[n]["port"])
|
||||
a_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
|
@ -371,7 +372,11 @@ class Music(commands.Cog, wavelink.WavelinkMixin):
|
|||
await self.bot.wavelink.initiate_node(**nodeValues[n]) # Port isn't open -> a service is behind, connecting...
|
||||
n += 1
|
||||
else:
|
||||
timeout -= 1
|
||||
sleep(1) # Port is open -> no service behind, retrying in 1 second...
|
||||
|
||||
if timeout <= 0:
|
||||
raise TimeoutError
|
||||
|
||||
@wavelink.WavelinkMixin.listener()
|
||||
async def on_node_ready(self, node: wavelink.Node):
|
||||
|
|
Reference in a new issue