jewlexx/discord-presence

Failed to connect: IoError(Os { code: 2, kind: NotFound, message: "No such file or directory" })

Closed this issue ยท 16 comments

The rpc application is normally created on https://discord.com/developers/applications/

fn main() {
	App::new()
		.add_plugins(DefaultPlugins)
		.add_plugin(RPCPlugin(RPCConfig{
			app_id: token(),
			show_time: true,
		}))
                .add_system(update_presence)
		.run();
}

fn update_presence(
	mut state: ResMut<ActivityState>,
){
        state.instance = Some(true);
        state.details = Some("Hello World".to_string());
        state.state = Some("This is state".to_string());
}

Function token() simply returns my token variable
But I get this error for some reason:
Failed to connect: IoError(Os { code: 2, kind: NotFound, message: "No such file or directory" })

EDIT:
OS: Ubuntu Budgie 20.04
Kernel: 5.13.0
Library Version: 0.2.2 (0.5.2)
Bevy Version: 0.7

Could you please add the following information:

OS: Eg. Windows
Kernel: (only if on Linux) Eg. 5.17
Library Version: Eg. 2.1.7
Base library or user within Bevy,

Thanks :)

If I am not mistaken, this occurs when the user does not have Discord open.

I will ensure that this error does not result in a process kill ever as it shouldn't.

Will be resolved in #4

Could you please add the following information:

OS: Eg. Windows Kernel: (only if on Linux) Eg. 5.17 Library Version: Eg. 2.1.7 Base library or user within Bevy,

Thanks :)

I've added this information, sorry

If I am not mistaken, this occurs when the user does not have Discord open.

I will ensure that this error does not result in a process kill ever as it shouldn't.

And the Discord is openned. It's not snap/flatpak, but only regular .deb

After update to 0.5.2 the error is not shown, but it still freezes and nothing happens :(
Discord is still opened

Please, @jewlexx , reopen the issue :)

@andezitgq Thank you for adding the info. I believe that this is an issue with how Linux installs the Discord application.

Could you clone this repository, and checkout fix/unix, then run cargo run --bin discord_presence and let me know if it works.

I've found out the problem - it was because of snap installation (but I thought it was regular :P). In .deb installation all works fine, but I am afraid, whether a user will have snap installation or simply a closed Discord, and his game will crash ;(
Could you make an app not crash if not finding a launched copy of Discord, but ignore it?

EDIT
And also it started lagging very much in my game with RPC
EDIT
It lags, because I am updating RPC every frame, it takes too much network requests, so I know how to fix it. But the problem of game freezing, when Discord is inactive exist

it was because of snap installation

Yeah snaps are incredible ๐Ÿ™„. I'll have to do some testing locally when I'm home to see if I can fix implementations within Snaps, but it should work fine with Flatpak and regular deb installation.

Could you make an app not crash if not finding a launched copy of Discord, but ignore it?

I'll see if I can set it to return an error to the end developer so they can handle it accordingly, because for most games it will not be important to worry about but for some applications Discord presence might be vital.

It lags, because I am updating RPC every frame, it takes too much network requests, so I know how to fix it. But the problem of game freezing, when Discord is inactive exist

Yeah definitely do not update RPC every frame. This will cause not only processing issues but rate limits from Discord.
I am not sure why the game is freezing. If you can replicate it and send over a minimal project so I can debug it a bit more because I have not been able to replicate this issue.

I am not sure why the game is freezing.

Freezing = crashing, because in the example the game doesn't crash immediately, but "freeze", if Discord is closed

I haven't been able to replicate this issue on my end. If you could link a repository with a minimal example, or even just a main.rs file so I can replicate it and debug some more.

Sorry for inaction, you wanted a minimial example, which makes the issue, so there is: https://gist.github.com/andezitgq/c12e19fa7e3fd41c75ed0277299d9593

It is a simple code, made from bevy example, where it works, when Discord is openned, and freezes the game, when it is closed. It is pretty strange, that nobody have opened the issue yet.

Also after update to 0.5.3 there is an another error now...
Failed to connect: IoError(Os { code: 111, kind: ConnectionRefused, message: "Connection refused" })

I am unfortunately still unable to replicate the issue. The game doesn't seem to freeze and I don't get any error message.

Could you please describe in detail what happens vs what you expect to happen?

I noticed you're on Ubuntu Budgie so I will quickly install that in a VM and see if that allows me to reproduce the issue.

Could you please describe in detail what happens vs what you expect to happen?

I don't actually know, what to add :)
I've noticed, that in your code there is creating a thread of connection, and there, if it doesn't connect, it freezes the thread for 10 seconds and tries to reconnect each time, so it is an infinite loop. Could you try to rethink it? I'll try it too by myself

I've downloaded discord-presence and bevy-discord-rpc packages manually, having compiled them, and... It is working :)
Error message is the same, but it doesn't freeze anything. Maybe there is a problem in one of the packages of crates.io.

I've downloaded discord-presence and bevy-discord-rpc packages manually, having compiled them, and... It is working :) Error message is the same, but it doesn't freeze anything. Maybe there is a problem in one of the packages of crates.io.

Nice to hear it is working! I'll update the crates.io index ASAP

I am going to work on moving to the tracing crate for logging, which will allow the developer to hide the error messages should they please (I will put them under the debug log level)