Go app in debian container hangs when connecting to atlas with automatic encryption

I have gotten the sample code here mongodb-university/docs-in-use-encryption-examples/blob/main/queryable-encryption/go/local/reader to run on macOS (using libmongocrypt installed with brew, and the shared_lib). No issues there.

I’m now trying to run the same code in an amd64/debian:bullseye container connecting to an atlas cluster (M10, version 6.0.4).

It compiles, but hangs when it reaches this line: docs-in-use-encryption-examples/make-data-key.go at 8d823bba56e62a429b330072a6b364bc0e097cf1 · mongodb-university/docs-in-use-encryption-examples · GitHub
I’ve tried setting timeouts in the client options but it just hangs until I stop the container, never returning any error or printing anything. The prior db commands are successful and I can see the data keys created in atlas.

Adding in prints myself, I can see that this is the last line that runs: mongo-go-driver/client.go at b504c38406a5e7c45e1f77a8d2d9e938358cc695 · mongodb/mongo-go-driver · GitHub before the application hangs.

  • libmongocrypt and libbson are installed with apt-get and the application is compiled with “-tags cse”
  • The docker container has sufficient memory and cpu
  • Confirmed that the go application can open/read the shared_lib .so file
  • I’ve tried shared_lib 6.0.4 and 6.0.5-rc1 and see the same issue
  • go 1.15
  • go.mongodb.org/mongo-driver v1.11.2
  • libmongocrypt-dev (1.8.0~20230308+gitefaeb8e385-0).

Can anyone see what I might be doing wrong, or provide methods to debug?

@danny_fry The issue seems to be that the Go application is hanging when it reaches a certain line of code while trying to connect to an Atlas cluster. The last line that runs successfully has been identified, but no error or output is being returned.
Some possible issues could be:

  • Incorrect authentication credentials or network settings. It is important to ensure the Go application is using the correct Atlas connection string and database user credentials.
  • Firewall or network issues preventing the Go application from establishing a connection to the Atlas cluster. It may be helpful to check if there are any special network or firewall rules that need to be set.
  • Compatibility issues with the Atlas cluster or MongoDB driver. It may be helpful to check if the version of the MongoDB driver being used in the Go application is compatible with the version of the Atlas cluster being used.

Some suggested methods to debug the issue could be:

  • Adding print statements at various points in the code, to verify which lines of code are being executed and which ones are hanging.
  • Checking the MongoDB server logs to see if there are any relevant error messages or status codes that could indicate what the issue is.
  • Using a tool such as Wireshark to inspect the network traffic and see if the Go application is able to establish a connection to the Atlas cluster.
  • Trying to run the same Go application on a different machine or environment to see if the issue is specific to the current environment.

I resolved this issue by adding .SetBypassQueryAnalysis(true) to the options in this line: docs-in-use-encryption-examples/make-data-key.go at 8d823bba56e62a429b330072a6b364bc0e097cf1 · mongodb-university/docs-in-use-encryption-examples · GitHub but I didn’t look more closely at what the problem was or why this fixed it.

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.