Azure Data Factory Linked Service Connection Timeout Error with MongoDB

Hari Ramamurthy 0 Reputation points
2024-11-19T03:53:52.4433333+00:00

Experiencing an error while trying to connect to MongoDB from a linked service in Azure Data Factory.

Connection to MongoDB server is timeout.

A timeout occurred after 30000ms selecting a server using CompositeServerSelector{ Selectors = MongoDB.Driver.MongoClient+AreSessionsSupportedServerSelector, LatencyLimitingServerSelector{ AllowedLatencyRange = 00:00:00.0150000 } }.

Client view of cluster state is { ClusterId : "3", ConnectionMode : "Automatic", Type : "Unknown", State : "Disconnected", Servers : [{ ServerId: "{ ClusterId : 3, EndPoint : "xx.xxx.xx.xxx:xxxxx" }", EndPoint: "xx.xxx.xx.xxx:xxxxx", State: "Disconnected", Type: "Unknown", HeartbeatException: "MongoDB.Driver.MongoConnectionException: An exception occurred while opening a connection to the 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 xx.xxx.xx.xxx:xxxxx

at System.Net.Sockets.Socket.InternalEndConnect(IAsyncResult asyncResult)

at System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult)

at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization)

--- 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 MongoDB.Driver.Core.Connections.TcpStreamFactory.<ConnectAsync>d__7.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 MongoDB.Driver.Core.Connections.TcpStreamFactory.<CreateStreamAsync>d__4.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 MongoDB.Driver.Core.Connections.BinaryConnection.<OpenHelperAsync>d__51.MoveNext()

--- End of inner exception stack trace ---

at MongoDB.Driver.Core.Connections.BinaryConnection.<OpenHelperAsync>d__51.MoveNext()

--- End of stack trace from previous location where exception was thrown ---

at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()

at MongoDB.Driver.Core.Servers.ServerMonitor.<HeartbeatAsync>d__28.MoveNext()", LastUpdateTimestamp: "2024-11-19T03:14:01.0739384Z" }] }.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,923 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Ganesh Gurram 1,510 Reputation points Microsoft Vendor
    2024-11-19T19:10:10.07+00:00

    @Hari Ramamurthy - Thanks for the question and using MS Q&A forum.
    According to this documentation: Copy data from or to MongoDB using Azure Data Factory or Synapse Analytics

    The following properties are supported for MongoDB linked service:

    User's image Below image shows the supported capabilities for the MongoDB connector:User's image

    Here are some steps you can take to troubleshoot and resolve this issue:

    • Ensure that the firewall settings on your MongoDB server allow incoming connections from the Azure Data Factory IP ranges. You may need to whitelist the IP addresses used by ADF.
    • If your MongoDB is hosted in Azure (e.g., on an Azure VM), check the NSGs associated with the VM to ensure that they allow traffic on the port MongoDB is using (default is 27017).
    • If you are using the Auto Resolve Integration Runtime, it might change regions, causing connectivity issues. Consider setting up a self-hosted integration runtime and ensure its IP address is whitelisted in MongoDB.
    • If the MongoDB server is under heavy load or if there are network latency issues, consider increasing the connection timeout settings in the ADF linked service configuration.

    For more details refer to this MS documentation: Create a linked service to MongoDB using UI

    Copy data from or to MongoDB using Azure Data Factory or Synapse Analytics

    Troubleshoot the MongoDB connector in Azure Data Factory and Azure Synapse

    Hope this helps. Do let us know if you have any further queries.  

    ------------- 

    If this answers your query, do click `Accept Answer` and `Yes` for was this answer helpful. And, if you have any further query do let us know.  


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.