-
Notifications
You must be signed in to change notification settings - Fork 416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Voice receive broken for reconnected voice connections #359
Comments
OK, never mind, the bug is SLIGHTLY weirder than I'd realized, as the actual output is:
i.e., the disconnect event fires into the PREVIOUS session's callback. I assume the VoiceConnection is being reused, but it appears to be reused in a nonworking way. |
Behold, the world's cheekiest (and thus best) workaround: const fs = require("fs");
const Eris = require("eris");
const config = JSON.parse(fs.readFileSync("config.json", "utf8"));
const client = new Eris(config.token);
var counter = 0;
function session(connection, guild) {
const sessionNum = ++counter;
console.log("Starting session " + sessionNum);
const opus = connection.receive("opus");
opus.on("data", ()=>{
console.log(sessionNum);
});
connection.on("disconnect", ()=>{
console.log("Ending session " + sessionNum);
client.voiceConnections.delete(guild.id);
});
}
client.on("messageCreate", (msg) => {
if (msg.content === "join") {
if (msg.member && msg.channel.guild && msg.member.voiceState.channelID) {
var channel = msg.channel.guild.channels.get(msg.member.voiceState.channelID);
if (!channel) return;
channel.join({opusOnly:true})
.then((connection)=>{session(connection,msg.channel.guild);})
.catch(console.error);
}
} else if (msg.content === "leave") {
if (msg.channel.guild) {
var me = msg.channel.guild.members.get(client.user.id);
if (!me) return;
var cid = me.voiceState.channelID;
if (!cid) return;
var channel = msg.channel.guild.channels.get(cid);
if (!channel) return;
channel.leave();
/*
var vc = client.voiceConnections.get(msg.channel.guild.id);
if (!vc) return;
vc.disconnect();
*/
}
}
});
client.connect(); So, yes, it has something to do with mis-reusing the voice connection. Presumably any existing VoiceConnection should universally be scrapped if you're doing a fresh join. |
Something on your end appears to have swallowed a rather useful error stacktrace
|
* upstream/master: 0.8.5 Add option to manually offset ratelimiter Add Eris.VERSION (abalabahaha#364) Avoid negative average latency (fix abalabahaha#365) Code/docs tidying Check for missing msg.author in CommandClient (fix abalabahaha#362) Fix voice receive stream cleanup (fix abalabahaha#359) Fix Spotify presence update caching (abalabahaha#363) Update editStatus docs (abalabahaha#361) Expose userID for CommandClient reaction buttons Expose activity and application properties in Message Fix user caching for ban events
* upstream/master: 0.8.5 Add option to manually offset ratelimiter Add Eris.VERSION (abalabahaha#364) Avoid negative average latency (fix abalabahaha#365) Code/docs tidying Check for missing msg.author in CommandClient (fix abalabahaha#362) Fix voice receive stream cleanup (fix abalabahaha#359) Fix Spotify presence update caching (abalabahaha#363) Update editStatus docs (abalabahaha#361) Expose userID for CommandClient reaction buttons Expose activity and application properties in Message Fix user caching for ban events
If you connect to a voice channel in a guild, disconnect, then connect to a voice channel again (same or different), the second fails to receive any data, although showing all signs of connecting successfully. Example code:
Expected output:
Actual output:
Note that I somewhat naughtily used the undocumented VoiceConnection.disconnect function instead of VoiceChannel.leave, but the result is the same either way, it was just easier in this example :)
The text was updated successfully, but these errors were encountered: