1

I have a node.js app running in Azure as an App Service. It connects to MongoDB via mongoose + tunnel-ssh. I have multiple App Services deployed in various geo locations and everything works just fine.

When I create a staging slot I get following error from ssh tunnel for the staging instance (note: prod. slot still works fine):

{"code":"EADDRINUSE", "errno":"EADDRINUSE", "syscall":"listen", "address":"127.0.0.1", "port":27017}

To me, it seems that staging slot is running on same VM and tries to use the same port as production and that's why it cannot establish a connection to DB. This means that I probably won't be able to scale out the app as another instance would have the same problem.

How can I solve this both for staging and for other instances (when scaling)?

Staging could use a different port, but how to set it up dynamically so it would work also for scaled instances?

demongolem
  • 9,474
  • 36
  • 90
  • 105
Michal
  • 11
  • 1

1 Answers1

0

According to your error message, it seems that you forget to configure the MongoDB's connection string for your slot Web App application.

As we can find the sentence at the instruction at Set up staging environments in Azure App Service:

Deployment slots are actually live apps with their own hostnames. App content and configurations elements can be swapped between two deployment slots, including the production slot.

Essentially, you can treat the slots as separate Web Apps. So please double check your application configurations in your slot applications.

Gary Liu
  • 13,758
  • 1
  • 17
  • 32
  • I did more digging - I've isolated my web app so no one except me was able to access it. I've restarted both prod and stg slot and I ended up in the same situation - prod was able to connect to DB via SSH, stg not. When I stopped prod, stg was suddenly able to connect, but after enabling prod the whole problem was moved on this slot. This seems to me that only one slot can create and use ssh tunnel (use the port). – Michal Mar 06 '17 at 14:49
  • Which mongodb service you are using? As it confused me your what error message showed `"address":"127.0.0.1"`. Currently, you can enable the different port of your mongodb for your slots, and set different application settings in different slots for the mongodb connection string, as a workaround. – Gary Liu Mar 07 '17 at 02:03
  • It's MongoDB with replication from Bitnami hosted in Azure. The address is localhost because I have a ssh tunnel created that forwards the traffic to public IP of my VM which hosts Mongo. Configuration should be ok, as it works for one slot. Problem is that second one can't establish connection. – Michal Mar 07 '17 at 06:29