Facepunch / Facepunch.Steamworks

Another fucking c# Steamworks implementation
MIT License
2.83k stars 340 forks source link

SteamNetworkingSockets Connect Relay Disconnects immediately #706

Open GeorgeA93 opened 1 year ago

GeorgeA93 commented 1 year ago

Describe the bug

On OSX 12.5.1 I cannot connect to a local P2P server, however I can on Windows 10 and 11.

As far as I can tell I am able to connect to the steam relay server, and it figures out that my server is running on the same machine so it tries to connect via loopback, but as soon as it tries to connect, the client disconnects. However on windows, this is not the case, the client connects absolutely fine.

For testing I am running steam in the background with the same user logged in, I have also tried different users but to no avail.

To Reproduce Steps to reproduce the behavior:

  1. Git clone https://github.com/GeorgeA93/monogame-net-test (Super simple repro case, just runs a client and server through monogame)
  2. You will also need facepunch.steamworks (see my csproj file to where to place it)
  3. Run with dotnet run

Expected behavior

The server should connect, but it does not.

Desktop (please complete the following information):

Additional context

I can also not connect remotely from a another machine, however I can connect out from this Mac to a Windows machine. Very strange.

I have added a lot of logging and it looks like this:

Connected to steam relay - starting server
Started server
Connecting to server
Requesting cert for [U:1:1004051581] from Steam
AuthStatus (steamid:76561198964317309):  Attempting  (Requesting cert)
[#3639463094 pipe] Using loopback for P2P connection to local identity steamid:76561198964317309 on vport 0.  Partner is [#3965445919 pipe]
[Callback SteamNetAuthenticationStatus client]
     Avail: Attempting
  DebugMsg: System.Byte[]

[Callback SteamNetConnectionStatusChangedCallback client]
      Conn: 3965445919
       Nfo: Steamworks.Data.ConnectionInfo
  OldState: FindingRoute

[Callback SteamNetConnectionStatusChangedCallback client]
      Conn: 3639463094
       Nfo: Steamworks.Data.ConnectionInfo
  OldState: Connecting

CLIENT DISCONNECT
[Callback SteamAPICallCompleted client]
  AsyncCall: 9729060269119876774
   Callback: 1296
 ParamCount: 792

[Callback 1296 client]
[no callback waiting/required]

[Callback SteamNetAuthenticationStatus client]
     Avail: Current
  DebugMsg: System.Byte[]

Got cert for steamid:76561198964317309 from Steam
AuthStatus (steamid:76561198964317309):  OK  (OK)
Certificate expires in 43h36m at 1676732695 (current time 1676575732), will renew in 41h36m
RouterPingReply from maa#26 (155.133.232.98:27040), 285ms

You will notice in the above that the CLIENT DISCONNECT happens straight away (this is a log in the connection managers OnDisconnect callback for the client). This happens after receiving connection info with the state None. My theory is that OSX is dropping a packet somewhere. I will eventually get a log saying the connection timed out as the connection was not accepted.

When I try connecting to the OSX server from a windows machine I get the following logs on the OSX side:

[#699822510 P2P steamid:76561198014888854 vport 0] Received incoming P2P connect request; awaiting app to accept connection
[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes, revision 1.  Contains 6 clusters and 0 routes
[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[#699822510 P2P steamid:76561198014888854 vport 0] ICE failed 4999 Peer sent signal without ice_enabled set
[Callback SteamNetConnectionStatusChangedCallback client]
      Conn: 699822510
       Nfo: Steamworks.Data.ConnectionInfo
  OldState: None

[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in SDK]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[Callback 1298 client]
[1298 not in sdk]

[#699822510 P2P steamid:76561198014888854 vport 0] Received P2P routes ack for revision 0 (latest revision is 0).
[#699822510 P2P steamid:76561198014888854 vport 0] Application didn't accept or close incoming connection in a reasonable amount of time.  This is probably a bug in application code!
[#699822510 P2P steamid:76561198014888854 vport 0] problem detected locally (5003): App didn't accept or close incoming connection in time.
[#699822510 P2P steamid:76561198014888854 vport 0] Sending graceful P2P ConnectionClosed, remote cxn 164513920
[#699822510 P2P steamid:76561198014888854 vport 0] Sending P2PRendezvous (ConnectionClosed)
[Callback SteamNetConnectionStatusChangedCallback client]
      Conn: 699822510
       Nfo: Steamworks.Data.ConnectionInfo
  OldState: None

It also smells very similar to https://github.com/Facepunch/Facepunch.Steamworks/issues/387 but I have tried to stop as many other services as possible when running the test and it doesn't seem to help. Also, I'm not running chromium.

I have also been trawling through the network traffic with wireshark + tcpdump but cannot for the life of me figure out why this is happening, it is just connecting over the loopback so should be fine.

Let me know if this is actually a bug with steamworks, not facepunch! Anything you can suggest to help me debug would also be much appreciated.

Thanks!

TrevTV commented 1 year ago

I'm having nearly the same issue, did you ever find a solution?

TrevTV commented 1 year ago

I ended up replacing this library with Steamworks.NET. It's a lot more annoying to work with but seems to work fine

GeorgeA93 commented 1 year ago

Never found the issue sadly. You won't like this resolution, but I actually replaced my laptop recently (macbook pro 2019 for an M2 air) and it just started working.... Absolutely no idea why.

I also contemplated switching to that lib as a test, but didn't like the look of the interface. I might still have to if this issue impacts other devices.

TrevTV commented 1 year ago

That's odd, I figured it would have been with all MacOS devices.

Steamworks.NET is a lot weirder than Facepunch, and looks a lot messier, but once you get used to it it's not terrible.