Skip to content
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

Steamworks.GameServer.Init doesn't take 6 arguments / gameserver.init "bad_response" #407

Closed
CodeSteel opened this issue Apr 6, 2021 · 16 comments

Comments

@CodeSteel
Copy link

CodeSteel commented Apr 6, 2021

Steam.cs : lines 156/162

public static bool Init(uint unIP, ushort usAuthPort, ushort usGamePort, ushort usQueryPort, EServerMode eServerMode, string pchVersionString) { // added AuthPort variable 
            InteropHelp.TestIfPlatformSupported();

            bool ret;
            using (var pchVersionString2 = new InteropHelp.UTF8StringHandle(pchVersionString)) {
                ret = NativeMethods.SteamInternal_GameServer_Init(unIP, usAuthPort, usGamePort, usQueryPort, eServerMode, pchVersionString2); // use NativeMethods.SteamInternal_GameServer_Init instead
}

Steamworks GameServer won't initialize correctly without the Authentication port, this allows the use of the Authentication port.

@d3v1l401
Copy link

d3v1l401 commented Apr 6, 2021

I've lost 4 hours trying to figure out why my game server won't show up in my game servers list, turns out this is the reason...

@JamesMcGhee
Copy link
Contributor

We have had a couple clients report this item but haven't been able to investigate further our selves

@rlabrecque
Copy link
Owner

Hmm this was removed in 1.51 here:

rlabrecque/SteamworksSDK@4d41594#diff-cfb093ce0838f6b6a98c27d3fa7ec8b56400a5e0c832732768c741425124c24d

And updated accordingly in Steamworks .NET:

6527a29#diff-8a013c2d5ffcd2336c8cbecf9484539d11f198f89f6b7e005266cbb5822b30e2

Are you using the 1.51 steam_api.dll?

The SDK only ever sets it to 0 now, @fletcherdvalve do you know anything about this?

@JamesMcGhee
Copy link
Contributor

In the 2 cases above its from one of our clients which is using the latest unitypackage release from the release options

@zpostfacto
Copy link

zpostfacto commented Apr 6, 2021

Yeah, the usSteamPort port argument is not used. I didn't modify SteamInternal_GameServer_Init, I only changed the inline function in the header to remove it and pass a zero to SteamInternal_GameServer_Init. Later we might update steam_api.dll to remove that argument from SteamInternal_GameServer_Init as well.

@JamesMcGhee
Copy link
Contributor

It seems that since this change we are seeing clients with issues initalizing GameServer may not be related but wanted to raise it here.

"still have the same issue with the server trying to bind to port 1 for some unknown reasons
game port is set to 27015, query is 27016"

{"response":{"success":true,"servers":[{"addr":"35.180.225.114:1","gmsindex":-1,"appid":1560620,"gamedir":"e.g. its folder name","region":-1,"secure":false,"lan":false,"gameport":27016,"specport":0}]}}

So when we check we can see it is binding on port 1 as well as 27015 and 27016 not sure why its binding on port 1

@JamesMcGhee
Copy link
Contributor

Also on this test we set params as such

(0, 7777, 7778, eServerModeNoAuthentication, 1.0.0.0)

but this is what we see in responce
{"response":{"success":true,"servers":[{"addr":"78.194.68.247:1","gmsindex":-1,"appid":1560620,"gamedir":"e.g. its folder name","region":-1,"secure":false,"lan":false,"gameport":7778,"specport":0}]}}

note game port bound to 7778 but should be 7777 also the addre shouldn't be on port 1

@JamesMcGhee
Copy link
Contributor

From a client
They ran a test manually calling GameServer_Init and setting the steam port

ushort usSteamPort = 8866;
                ret = NativeMethods.SteamInternal_GameServer_Init(unIP, usSteamPort, usGamePort, usQueryPort, eServerMode, pchVersionString2);

the same fix as the #1 post

This resulted in
{"response":{"success":true,"servers":[{"addr":"78.194.68.247:7778","gmsindex":-1,"appid":1560620,"gamedir":"e.g. its folder name","region":-1,"secure":false,"lan":false,"gameport":7777,"specport":0}]}}

Which is as expected so seems an issue with the GameServer.Init(...)

@JamesMcGhee
Copy link
Contributor

I have done a re-read and some more testing on this one

  1. using the source from this project directly so the assemblies are the ones included in this project's Plugin folder.

  2. As is e.g. without any changes when we initalize GameServer.init ... we see the issue reported above, that is the odd looking UDP port binding on port 1 and the server will not show up in Steam Game Server Browser either via query through the API nor via the view in the Steam Client.

  3. If we modify Steam.cs to call SteamInternal_GameServer_Init passing in any value even 0 as the second param the most apparent issues appear to resolve and the server shows up in the browser.

Having a look over the change you linked from Steamworks SDK and the related steam_gameserver.h I do see a note there

// SteamGameServer_InitSafe has been replaced with SteamGameServer_Init and
// is no longer supported. Use SteamGameServer_Init instead.

When I examen the NativeMethods.cs of Steamworks.NET for the method in question SteamGameServer_Init I see its referencing an entry point SteamGameServer_InitSafe

[DllImport(NativeLibraryName, EntryPoint = "SteamGameServer_InitSafe", CallingConvention = CallingConvention.Cdecl)]

That is as far as I got, its far to late in the evening :) ... or well early in the day now :( ... to keep poking
Hopfully that is of some use to others

@rlabrecque
Copy link
Owner

I think you found the problem! Should have time to investigate right away, That should NOT be pointing to InitSafe anymore.

@rlabrecque
Copy link
Owner

Pushed live on both master, and the new unity-package branch! Good find @JamesMcGhee! Could you try this out with your repro case? If this works for you I want to get a new release out with this right away.

@blacklagoonfr
Copy link

blacklagoonfr commented Apr 10, 2021

With the fix i'm experiencing an EntryPointNotFoundException: SteamGameServer_Init error, after trying to find the entry point name, it's still referenced as SteamGameServer_InitSafe and/or has no reference to SteamGameServer_Init inside the 1.51 bin.
I tested with both the latest Steamworks.NET steam_api64, and Steamworks SDK steam_api64 libraries from github.

@JamesMcGhee
Copy link
Contributor

Same sort of responce as @blacklagoonfr

EntryPointNotFoundException: SteamGameServer_Init
  at (wrapper managed-to-native) Steamworks.NativeMethods.SteamGameServer_Init(uint,uint16,uint16,Steamworks.EServerMode,Steamworks.InteropHelp/UTF8StringHandle)
  at Steamworks.GameServer.Init (System.UInt32 unIP, System.UInt16 usGamePort, System.UInt16 usQueryPort, Steamworks.EServerMode eServerMode, System.String pchVersionString) [0x0000d] in <a44e830549354e84ab530397f6627ad9>:0
  at HeathenEngineering.SteamAPI.SteamSettings.Init () [0x00152] in <4f23ef20f3484b148221c2f1d0768901>:0
  at HeathenEngineering.SteamAPI.ClientApiSystem.InitializeGameServer () [0x001ed] in <4f23ef20f3484b148221c2f1d0768901>:0
  at HeathenEngineering.SteamAPI.ClientApiSystem.OnEnable () [0x00029] in <4f23ef20f3484b148221c2f1d0768901>:0

My steps where

  1. Pull latest from Git
  2. swap out the plugins folder
  3. build and run server
  4. Initalize via Steam API: GameServer.Init(0, 27015, 27016, eServerModeNoAuthentication, 1.0.0.0)
    which gave us the above exception

@rlabrecque
Copy link
Owner

Hrm, okay that makes sense since it's inline. Looks like the original suggestion of using SteamInternal_GameServer_Init is probably the ideal one then!

@rlabrecque rlabrecque reopened this Apr 10, 2021
@JamesMcGhee
Copy link
Contributor

That's the worksround we are using at the moment
Simply passing in a value of 0 on the usSteam port I think the param is called.

We are seeing issues with GameServers not getting messages from clients when using SteamNetworking or SteamNetworkingSockets (and its GameServer varients) even with this work around in place. That issue may be releated to something else around Mirror or similar but was hoping the server intialization and transport issue was related for a single easy fix :)

For the moment we using a modified Steam.cs which calls SteamInternal_GameServer_Init, from what I saw in the game server header this is what SteamGameServer_Init does anyway so I think that will do us for now.

@oalpar
Copy link

oalpar commented May 9, 2022

I am also having the same error but I am not sure how to fix this, package is downloaded through the package manager and doesnt allow me to access native NativeMethods.SteamInternal_GameServer_Init or modify the codes. Is only way to fix downloading from github and changing it manually? Why do we need to call NativeMethods.SteamInternal_GameServer_Init instead of GameServer.init?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants