Nodejs application docker unable to connect to mongodb docker container

I have a nodejs application which dockerized and need a replicated MongoDB database. I have built my replicated MongoDB in docker-compose and working just fine. if I run the command docker inspect MongoDB-primary |grep IPAddress its print:

"IPAddress": "",             "IPAddress": "", 

now in my application, i give this ip as mongoconnection string(of course with protocol names) but the application cannot connect to MongoDB and throw this error message(application also is a docker container):

 message: 'failed to connect to server [] on first connect [MongoNetworkError: connection 1 to timed out]', 

how can I fix this?