Error 51 whilst trying to connect
Opened this issue · 12 comments
I've implemented this project into my game built with Godot 3.5.2, running it on Linux works perfectly fine at works great! But whenever i try running the game on windows it errors out and gives me errors 51 and i was wondering what it meant?
this is the relevant code in case i just completely missed something
func _ready() -> void:
add_child(discord_rpc)
discord_rpc.connect("rpc_error", self, "_on_discord_error")
discord_rpc.connect("rpc_ready", self, "_on_discord_ready")
discord_rpc.establish_connection(APPLICATION_ID)
func _on_discord_error(error: int) -> void:
print("RPC Connection ERROR: ", error)
func _on_discord_ready(user: Dictionary) -> void:
print("yay")
alright nvm after a bit more searching i found out that it just can't find any clients connected
running thru and trying to understand what it's doing, it reaches this part of the code in DiscordRPC.gd
for i in range(10):
var path = IPC.get_pipe_path(i)
for final_path in [path] if not is_linux else [path % "", path % FLATPAK, path % SNAP]:
if _ipc.open(final_path) == OK:
_handshake()
return
_ipc.close()
it loops 10 times, the final_path
variable is set to \\?\pipe\discord-ipc-{loopCount}
the first check of _ipc.open(final_path) returns ERR_FILE_CANT_OPEN, subsequent checks returns ERR_FILE_NOT_FOUND
still have no idea what's going on as i'm not all that familiar with the discord RPC specification
Discord RPC is done through a Unix socket on Linux/MacOS and a Named pipe on Windows (think of the latter as a file)
Each Discord instance creates the socket/named pipe on an endpoint named discord-ipc-{instance_id}
where instance_id
is zero indexed. So establishing a connection is done by finding the endpoint and ensuring that the current application has read & write access to it.
so here is what I think is a possible cause of failure on windows:
- Discord is running with administrator privilege (the named pipe won't be accessible from programs with a lower privilege).
- You aren't running Discord desktop client (very unlikely from what I can tell)
it is also good to note that my implementation for Godot 3.x is poor comparing to the rewrite for Godot 4.x, I just don't happen to have time to invest on refactoring the 3.x branch
I've handed out the executable to multiple others, and they all seem to get the same read/write permission error so i doubt it's a privilege thing?
Do you have any other possible ideas?
Interesting... will try to investigate when I get on Windows
thanks for your time!
okay i seem to have got it working myself, it seems like my steam integration was blocking it?
idk if steam would just block file requests like that but it's possible?
Okay yea, steam itself does not block the file requests, however my integration layer with steam, "godotsteam" seems to be interfering
🤔 that's even weirder, are you using the GDNative version or as a Godot module ?
the godot module, more specifically the pre-compiled version
if it helps in any way, here's a minimum-reproducable-project.zip i made
In my Windows implementation I used Godot's File
object and was enough to connect to Discord RPC named pipe. I have tried vanilla Godot 3.5.1
, 3.5.2
and 3.5.3-rc1
all of which have worked fine, so it is clear that the issue comes from the Steam integration.
So I have inspected Godot's source code and found that they are using _wfsopen to deal with files on windows:
https://github.com/godotengine/godot/blob/5271c971f346fcf3859f5872049f948afa4dba99/drivers/windows/file_access_windows.cpp#L115
And there seems to be a way to intercept _wfsopen calls, however it's kinda hard to confirm whether this is the case since SteamworksSDK is closed source