You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run this code via a discord command, it will successfully send the command to the server, and successfully send the response of the command!
The .on('end',()) function fires off after exactly 1 hour.
So, attempting to run another command, within that hour, consistently results in:
"Error: connect ETIMEDOUT :".
The only way I've found to get around this limitation is to reboot my discord bot via process.exit(). Once rebooted, it will work one time again.
Having that been said, I am currently forcing my bot to reboot every time this particular discord command is ran, so that I can use commands without having to manually reboot.
(I've commented the process.exit() in the code below, as the below code is what is currently a 1-time-use command.
Is there a way to get around this? To limit the time the socket connection stays open? conn.disconnect(); does not disconnect the socket connection.
letRcon=require('rcon')constconn=newRcon(process.env.IP,process.env.PORT,process.env.PASSWORD);try{message.channel.send(`Please wait for Server Authentication:`)conn.connect();conn.on('auth',function(){// You must wait until this event is fired before sending any commands,// otherwise those commands will fail.message.channel.send(`Authenticated - Sending command: ${args.join(" ")}`);conn.send(args.join(" "));}).on('response',(str)=>{message.channel.send("Response: "+str);//process.exit()}).on('end',()=>{message.channel.send("Rcon socket closed!");}).on('error',(error)=>{message.channel.send(`Error ${error}`)conn.disconnect();});}catch(error){console.error(error)}
The text was updated successfully, but these errors were encountered:
It looks like the server-side socket is timing out since there's not much traffic on the connection. Two things you could try:
Disconnect the connection on response, and reconnect when you want to send another command. This makes sense if you're only sending commands once in a while.
Send a ping once in a while (e.g. every 10 seconds) to keep the connection alive. This makes sense if you're sending commands fairly frequently and want to ensure the lowest latency possible.
When I run this code via a discord command, it will successfully send the command to the server, and successfully send the response of the command!
The .on('end',()) function fires off after exactly 1 hour.
So, attempting to run another command, within that hour, consistently results in:
"Error: connect ETIMEDOUT :".
The only way I've found to get around this limitation is to reboot my discord bot via process.exit(). Once rebooted, it will work one time again.
Having that been said, I am currently forcing my bot to reboot every time this particular discord command is ran, so that I can use commands without having to manually reboot.
(I've commented the process.exit() in the code below, as the below code is what is currently a 1-time-use command.
Is there a way to get around this? To limit the time the socket connection stays open? conn.disconnect(); does not disconnect the socket connection.
The text was updated successfully, but these errors were encountered: