Rhino.Compute can't work with MongoDB?

Hi, dear fellow Rhino.Compute developers,

Help this poor soul please…Long story short, I created my own Rhino.Compute custom endpoint and deployed it to a EC2 instance. One of the methods from this custom endpoint uses MongoDB.Driver nuget package to update my MongoDB database, and this is the method that keeps failing and returning 500 error. Other methods that don’t interact with MongoDB can return successful responses!
However, I don’t get the error from the rhino.compute that running locally on my laptop. I confirmed it with my friend’s laptop, and everything executes successfully.
I suppose if Rhino.Compute running on our own laptops can successfully execute the method, it should be same for the EC2 instance, right?

Anyways, This is the error message from the EC2 log file, {"Timestamp":"2023-06-24T17:50:16.0574733+00:00","Level":"Error","MessageTemplate":"An exception occured while processing request","RenderedMessage":"An exception occured while processing request","Exception":"Newtonsoft.Json.JsonSerializationException: Error getting value from 'Result' on 'System.Threading.Tasks.Task1[System.String]'. —> System.AggregateException: One or more errors occurred. —> System.Exception: An exception occurred while opening a connection to the server.\r\n at DG.MDLCoreEndpoints.d__5.MoveNext()\r\n — End of inner exception stack trace —\r\n at System.Threading.Tasks.Task1.GetResultCore(Boolean waitCompletionNotification)\r\n at GetResult(Object )\r\n at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)\r\n --- End of inner exception stack trace ---\r\n at Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)\r\n at Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)\r\n at Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)\r\n at Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)\r\n at compute.geometry.GeometryEndPoint.HandlePostHelper(JArray ja, Dictionary2 returnModifiers) in /home/runner/work/compute.rhino3d/compute.rhino3d/src/compute.geometry/GeometryEndPoint.cs:line 445\r\n at compute.geometry.GeometryEndPoint.Post(NancyContext context) in /home/runner/work/compute.rhino3d/compute.rhino3d/src/compute.geometry/GeometryEndPoint.cs:line 384\r\n at compute.geometry.RhinoPostModule.<>c__DisplayClass0_0.<.ctor>b__0(Object _) in /home/runner/work/compute.rhino3d/compute.rhino3d/src/compute.geometry/Program.cs:line 227\r\n at Nancy.Routing.Route.<>c__DisplayClass4.b__3(Object parameters, CancellationToken context)",“Properties”:{“Port”:“6002”}}`

Many thanks in advance to the community!!!

Ok…Figured it out myself.
As a noob in exploring Rhino.Compute, I quickly find myself lacking much knowledge of cloud services. Apparently if the MongoDB IP is not whilisted for the EC2 security group, it will never reach EC2. Once I added it in, I get the response returned.

1 Like

I am glad you made it.
From what I know, standard procedure on cloud service:
1: Install database on server.
2: Create database with test data.
3: Access cloud service control panel and add whitelist (for MongoDB, port =27017)
4: Test database connection on client.

Good luck!