Problem with session.reject()
See original GitHub issueHi,
I’m facing a little issue with the session.reject()
method on the prePublish
event. If I have any kind of promise before the reject, the server let the user connect and imediatly disconnect it. If there is no promises before the reject, it doesn’t even let the user connect and I receive and error in the OBS. For clarification:
This let the user connect and imediatly disconnect it. Then, OBS reconnect a is disconnected again. It keeps on this loop.
this.nms.on('prePublish', async (id, path, args) => {
const stream_key = this.getStreamKeyFromStreamPath(path);
const session = this.nms.getSession(id);
try {
const user = await User.findOne({ where: { stream_key } });
if (!user) {
console.log(`[REJECT]: Stream Key ${stream_key} not found.`);
session.reject();
} else {
console.log(
`[SUCCESS]: ${user.username} connected with Stream Key ${stream_key}`
);
}
} catch (error) {
console.log(error.message);
}
});
If I don’t have any promises on the event listener like this:
this.nms.on('prePublish', async (id, path, args) => {
const stream_key = this.getStreamKeyFromStreamPath(path);
const session = this.nms.getSession(id);
session.reject();
});
I receive and error on OBS: “Could not access the specified channel or stream key, please double-check your stream key…”
I know it’s probably nothing to do with the package itself, but I couldn’t find a solution to make it rejects correctly and don’t even let the user connect when I’m using promises. So, if someone can point me where I am doing it worng, I would be grateful.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7
Top GitHub Comments
the best solution for this problem is by creating a list outside the nms.on(); the list include all the stream_key for all the users who register to the website for example:-
this code is not best performance but i just want to share to you the idea
I have same issue and resorted to editing the core functions rather than using the events. I will see if I can do a pull request to include this functionality.