Azure/azure-cosmos-db-emulator-docker

Unable to connect to Cosmos DB emulator through VM when using AllowNetworking

Closed this issue · 13 comments

Describe the bug
When attempting to connect to the latest version of the emulator through a networked path, I receive connection refused errors when navigating by the browser, and HTTP 503 (Substatus: 20003) errors when connecting via the CosmosDB C# API.

Note that this is not using Docker. I simply cannot find anywhere else to post this issue that's exclusively about the emulator. If there's a better space for posting issues about the local emulator, please let me know.

To Reproduce
Steps to reproduce the behavior:

  1. Setup a Windows 11 ARM VM on a macOS Host with a bridged network adapter (I used autodetect in this case but I don't think it matters). This was created via VMWare Fusion 13 Pro.
  2. Install version 2.14.12 of the emulator on the VM.
  3. Start up the emulator with the following: Microsoft.Azure.Cosmos.Emulator.exe /AllowNetworkAccess /KeyFile=C:\CosmosKey.
  4. Confirm access on the VM using localhost/127.0.0.1.
  5. Confirm firewall rules are in place on the VM.
  6. Export the certificate back to the host and install it properly.
  7. Return to the host and attempt to access the emulator via the IP address of the machine 1.2.3.4:8081/_explorer/index.html. See the "Connection Refused" error.
  8. Alternatively to step 7, try and connect using the C# API and receive the HTTP 503 errors.

Expected behavior
We can connect to the host and use the emulator over a network.

Desktop (please complete the following information):

  • OS: macOS Ventura 13.6 (ARM).
  • Any Browser
  • Emulator version 2.14.12.

** Did not use Docker. Used local installed version on a VM as recommended by the docs online. **

Additional context
Thanks to this issue which was closed and told to come here (Azure/azure-cosmos-dotnet-v3#4011) I confirmed that when running the newest version of the emulator, it was only binding to 127.0.0.1:8081. I managed to confirm that this is likely the issue by figuring out how to downgrade to an older version of the emulator, 2.14.9, and then running it and seeing that it in fact binds to 0.0.0.0:8081 as well as 127.0.0.1:8081. Version 2.14.9 appears to work perfectly as I expect. That may not be the only issue, but it does seem like one of the issues.

It also looks like it was reported a while back here: Azure/azure-cosmos-dotnet-v3#3800.

This is the issue that has been wracking me for over a week. Since the Docker image is unsupported on Mac M1/M2, I tried to use the Windows emulator on a VM. I kept wondering why I could not connect from the host. The /AllowNetworkAccess was step one. Still, port 8081 is not accepting connections. I thought it was the firewall, and kept trying every possible setting. I Wireshark'd to try to see what was going on. I enabled ICMP on the Windows VM and could see connections being made, so I knew networking was fine and the firewall was working as intended.

As @pseudoramble pointed out, it appears that the emulator is binding only to 127.0.0.1 and not to the IP of the machine/VM. This is confirmed via netstat -a -b:

 [svchost.exe]
  TCP    127.0.0.1:8081         WINDOWS-CF4JB7H:0      LISTENING
 [Microsoft.Azure.Cosmos.Server.exe]
  TCP    192.168.1.140:139      WINDOWS-CF4JB7H:0      LISTENING
 Can not obtain ownership information
  TCP    192.168.1.140:10251    WINDOWS-CF4JB7H:0      LISTENING
 [Microsoft.Azure.Cosmos.Master.exe]
  TCP    192.168.1.140:10251    WINDOWS-CF4JB7H:51578  ESTABLISHED
 [Microsoft.Azure.Cosmos.Master.exe]
  TCP    192.168.1.140:10252    WINDOWS-CF4JB7H:0      LISTENING
 Can not obtain ownership information
  TCP    192.168.1.140:10253    WINDOWS-CF4JB7H:0      LISTENING
 [Microsoft.Azure.Cosmos.Server.exe]
  TCP    192.168.1.140:10254    WINDOWS-CF4JB7H:0      LISTENING
 [Microsoft.Azure.Cosmos.GatewayService.exe]
  TCP    192.168.1.140:63552    20.42.73.140:https     TIME_WAIT
  TCP    192.168.1.140:63571    a23-33-40-147:https    ESTABLISHED

With the bindings to the IP address, everything worked:

nc -vz 192.168.1.140 10251
Connection to 192.168.1.140 port 10251 [tcp/*] succeeded!

Still, 8081 is hanging:

nc -vz 192.168.1.140 8081
^C
v1k1 commented

Hi @pseudoramble, Thanks for reporting this, this is a known bug in current version for Windows CosmosDB Emulator. This has been fixed internally, with the next release it would be fixed publicly as well.

@v1k1 Is there any update when a new public release will be available? The latest one is from March 20, 2023. This would be a major help for those of us on Mac M1/M2 to emulate Cosmos locally, since there is no available emulator support for Mac M1/M2.

@andyvanosdale we are aiming the release next week.

Hi @sajeetharan, do you have any update on a new emulator release? This would really improve our development greatly!

Hi, any news about this @sajeetharan ?

Hi @sajeetharan, i just saw that this Update was released in the release notes, but it seems that all the links still point to the old version. Is there another download for the msi installer? Thanks!

Can confirm that the link is still pointing to v2.14.12 instead of v2.14.16. Also, the latest Docker image tag has not been updated.

Looks like v2.14.16 was pulled from the release notes.

Hi everyone, Yes it was a docs issue. MicrosoftDocs/azure-docs#118734 the fix will go by end of this month

This appears to be fixed! However, I'm seeing a new issue with the Data Explorer when using the /AllowNetworkAccess switch where data is unable to be explored. This seems it is because the Key or KeyFile provided to the command line is not used by the Data Explorer.

This appears to be fixed! However, I'm seeing a new issue with the Data Explorer when using the /AllowNetworkAccess switch where data is unable to be explored. This seems it is because the Key or KeyFile provided to the command line is not used by the Data Explorer.

Can you please open a new issue with the screenshots?