beamable / BeamableProduct

The beamable product suite including com.beamable, com.beamable.server, microservice base image, portal, the installer, and build scripts
Other
5 stars 0 forks source link

Microservice cannot connect to Micro Storage when Docker Desktop is above 4.30.0 #3576

Open allister-beamable opened 1 month ago

allister-beamable commented 1 month ago

Describe the Bug

After having upgraded Docker Desktop, whenever my C#MS invokes Storage stuff, there is a timeout error. First the client/service call times out at 10 seconds, then there is an error in the C#MS log after 30 seconds.

Exception "TimeoutException": "A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 }, OperationsCountServerSelector }. Client view of cluster state is { ClusterId : \"1\", Type : \"Unknown\", State : \"Disconnected\", Servers : [{ ServerId: \"{ ClusterId : 1, EndPoint : \"Unspecified/gateway.docker.internal:12101\" }\", EndPoint: \"Unspecified/gateway.docker.internal:12101\", ReasonChanged: \"Heartbeat\", State: \"Disconnected\", ServerVersion: , TopologyVersion: , Type: \"Unknown\", HeartbeatException: \"MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the server.

The MongoDB database is still reachable by tools like mongosh and MongoDB Compass, by pointing at mongodb://<username>:<password>@localhost:12101; the only problem seems to be the connection from C#MS to Storage.

To Reproduce

  1. Have a Unity Beamable project with at least one C#MS and at least one Micro Storage created from within Unity.
  2. Upgrade Docker Desktop to 4.31.0 or higher.
  3. Run the storage and the microservice.
  4. Enter playmode and do something that invokes Storage in the C#MS.

Expected Behavior

Actual Behavior

Metadata

Additional Context

Customers are able to work around this by avoiding local storage in favor of remotely-deployed Micro Storage.

cdhanna commented 1 month ago

I think another Beamable employee found that perhaps the local docker dns named has changed? In the GetLocalConnectionString method, we have a hardcoded default host value as "gateway.docker.internal". Perhaps that has changed?

In Unity 1.19.x, check the MicroserviceReflectionCache.GetConnectionString method; it also has the same reference to gateway.docker.internal

cdhanna commented 1 month ago

to actually fix this, we'll likely need to introduce a version number check for docker, or, find a way to read the host from somewhere

allister-beamable commented 1 month ago

There has gotta be a way to implement dynamic discovery. When services are run with Docker Compose, they magically get hostname entries in the network with which the containers are launched.