question

brian@baladongames.com avatar image
brian@baladongames.com asked

Heartbeat - SDK to AgentVM fails to connect

I'm trying to get started with the Multiplayer Servers 2.0 preview, but having trouble when the sdk starts trying to communicate to the MockAgentVM, when in container mode. I've tried both the sample and my own custom .net core 3 server app, and they each work properly when running "RunContainer: false" mode but throw exception on what I think is the first http connection from sdk to mockAgent, on the first heartbeat check, when running as "RunContainer: true". I also tried deploying the build, but the VM never made it past 'propping' stage, and besides I'd rather have it working in a mock setup first for development.

I'm not sure on how to proceed with debugging this, since things work when not in container, and the server itself also runs and can be connected to (even in container), it's just the sdk -> agentVM part that's not working.

Version Info (all-latest afaik):

  • "com.playfab.csharpgsdk" Version="0.9.190516" (my server)
  • "com.playfab.csharpgsdk" Version="0.9.190509" (sample server)
  • Docker version 19.03.1, build 74b1e89
  • MockAgentVM release 0.7

Exception:

2019-08-09T03:56:26.2798817Z	Cannot send heartbeat: An error occurred while sending the request.


System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond 172.19.0.11:56001
   at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)
   at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)
   at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Exception& exception)
   --- End of inner exception stack trace ---
   at System.Net.HttpWebRequest.EndGetRequestStream(IAsyncResult asyncResult, TransportContext& context)
   at System.Net.Http.HttpClientHandler.GetRequestStreamCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Playfab.Gaming.GSDK.CSharp.HttpClientProxy.<SendHeartbeatAsync>d__3.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Playfab.Gaming.GSDK.CSharp.InternalSdk.<SendHeartbeatAsync>d__52.MoveNext()

Custom Game Servers
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Sarah Zhang avatar image
Sarah Zhang answered

Maybe you didn’t bind the listener to the correct IP. Please try to bind the listener to “AnyIP”. For examples, string address = $"http://*:{listeningPort}/";” (http listener),or “IPAddress ipAddress = IPAddress.Any;” (socket).

3 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

brian@baladongames.com avatar image brian@baladongames.com commented ·

I'm not sure you saw, but this is a callstack of the sdk's async heartbeat check trying to communicate with the MockVmAgent, and not anything in user code. "Microsoft.Playfab.Gaming.GSDK.CSharp.InternalSdk.<SendHeartbeatAsync>" is the root of the callstack. My game's client code can actually connect just fine (even in this broken state), but things can't progress passed ReadyForPlayers() when the sdk never connects to the agent.

So the connection is between the gsdk and mockVmAgent, and not something where I can set either the connection or binding info. Whatever I'm doing wrong seems like it's got to be a configuration or version issue, and not a code issue I think, especially since the sample behaves the same way.

Currently it works in non-container mode using the mock agent, and on live deploys, so all that's missing is testing in container mode locally using the mock agent. However those two use cases are just fine for development, so it turns out this is not actually a hindrance.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang brian@baladongames.com commented ·

Sorry for some mistakes. So, may I ask did you run Setup.ps1 successfully and follow other things in this document?

0 Likes 0 ·
Garry Clark avatar image Garry Clark commented ·

I am having the same issue. Running outside container everything progresses as expected. When I set the RunContainer: true in the MultiplayerSettings.json I start getting this error in the log and the process hangs on waiting for heartbeat. I have ran the Setup.ps1 script and it succeeded.

Using version 0.9.190918 of the GameServerSDK

Was there ever a solution found?

2019-12-30T07:39:12.9008658Z	Cannot send 2019-12-30T07:38:51.2042901Z	VM Agent Endpoint: 172.19.0.11:56001
2019-12-30T07:38:51.2153977Z	Instance Id: 81bde313c2c05482d33d7984bbf86a9b90649c1d68db011bc39566d56cdc1e5f
2019-12-30T07:38:51.2412895Z	[PlayFabServerInstance] GameServer Starting
2019-12-30T07:39:12.9008658Z	Cannot send heartbeat: An error occurred while sending the request
System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: ConnectFailure (A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.