[BUG] Cosmos client connecting to wrong port when using emulator
See original GitHub issueDescribe the bug I have the cosmos emulator running on a container using port 9999 instead of 8081. I’m using the C# client to connect to it, but it just hangs indefinitly. Looking at the output window, I see that it’s trying to connect to port 8081 regardless of what my endpoint is.
Expected behavior It should connect to the correct port.
Actual behavior (include Exception or Stack Trace) It’s connecting to the wrong port.
DocDBTrace Information: 0 : DocumentClient with id 1 initialized at endpoint: https://localhost:9999/ with ConnectionMode: Gateway, connection Protocol: Https, and consistency level: null
DocDBTrace Information: 0 : Telemetry Disabled.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.10\System.Globalization.dll'.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Users\goenning\Desktop\CosmosLocalSDK\bin\Debug\net5.0\Microsoft.Azure.Cosmos.Core.dll'.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.10\System.Numerics.Vectors.dll'.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.10\System.Collections.Immutable.dll'. Symbols loaded.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.10\System.Runtime.CompilerServices.Unsafe.dll'. Symbols loaded.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.10\System.Security.Cryptography.Encoding.dll'. Symbols loaded.
DocDBTrace Information: 0 : SystemUsageMonitor started
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.10\System.Threading.Tasks.dll'.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.10\System.IO.dll'.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.10\System.Dynamic.Runtime.dll'.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.10\System.Runtime.Serialization.Formatters.dll'.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.10\System.Runtime.Numerics.dll'. Symbols loaded.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.10\System.Reflection.Emit.ILGeneration.dll'.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.10\System.Reflection.Primitives.dll'.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.0.10\System.Reflection.Emit.Lightweight.dll'.
'CosmosLocalSDK.exe' (CoreCLR: clrhost): Loaded 'Anonymously Hosted DynamicMethods Assembly'.
DocDBTrace Information: 0 : Current WriteEndpoints = (https://172.21.0.2:8081/) ReadEndpoints = (https://172.21.0.2:8081/)
DocDBTrace Information: 0 : GlobalEndpointManager: StartLocationBackgroundRefreshWithTimer() refreshing locations
Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Sockets.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Http.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Sockets.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Http.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Sockets.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Net.Http.dll
Exception thrown: 'System.Net.Sockets.SocketException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Net.Http.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in Microsoft.Azure.Cosmos.Client.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
Exception thrown: 'System.Net.Http.HttpRequestException' in System.Private.CoreLib.dll
DocDBTrace Warning: 0 : ClientRetryPolicy: Gateway HttpRequestException Endpoint not reachable. Failed Location: https://172.21.0.2:8081/; ResourceAddress: dbs/TEST
DocDBTrace Information: 0 : GlobalEndpointManager: Marking endpoint https://172.21.0.2:8081/ unavailable for read
DocDBTrace Information: 0 : Current WriteEndpoints = (https://172.21.0.2:8081/) ReadEndpoints = (https://172.21.0.2:8081/)
DocDBTrace Information: 0 : Endpoint https://172.21.0.2:8081/ unavailable for Read added/updated to unavailableEndpoints with timestamp 10/11/2021 09:42:39
DocDBTrace Information: 0 : GlobalEndpointManager: Marking endpoint https://172.21.0.2:8081/ unavailable for Write
DocDBTrace Information: 0 : Current WriteEndpoints = (https://172.21.0.2:8081/) ReadEndpoints = (https://172.21.0.2:8081/)
DocDBTrace Information: 0 : Endpoint https://172.21.0.2:8081/ unavailable for Write added/updated to unavailableEndpoints with timestamp 10/11/2021 09:42:39
DocDBTrace Information: 0 : Current WriteEndpoints = (https://172.21.0.2:8081/) ReadEndpoints = (https://172.21.0.2:8081/)
To Reproduce
- Start a cosmos emulator on linux container ( https://docs.microsoft.com/en-us/azure/cosmos-db/linux-emulator?tabs=ssl-netstd21 ) using port 9999 instead of 8081
- Write a simple C# script that connects to it.
- It’ll just hang indefinitly, look at output window.
Environment:
- Cosmos Emulator Image
sha256:42dd3146bf324c4c5fe59b23352b65c19b3780795c28da97f524e86cc32aa5ed
- Microsoft.Azure.Cosmos = 3.21.0
- Windows 10
- Visual Studio Enterprise 2019
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Troubleshoot issues when using the Azure Cosmos DB ...
Learn how to troubleshot service unavailable, certificate, encryption, and versioning issues when using the Azure Cosmos DB Emulator.
Read more >Adding Cosmos DB Emulator connection with alternate ...
In the "Connect to Cosmos DB" dialog, change the port in the AccountEndpoint value (or change anything about the AccountEndpoint value that ...
Read more >CosmosDB emulator can't start since port is already in use
The CosmosDbEmulator comes with a PowerShell module, which you can use to control it. To get started using the module run the following...
Read more >Setting Up Azure Cosmos DB Emulator for Development
While Azure Cosmos DB service can be an important storage system for your applications, sometimes using it during development can be ...
Read more >CosmosDB in a Containerized Dev Environment
In this article we cover: How to set up a containerized dev environment for CosmosDB development. How to configure the new CosmosDB emulator...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the info, I reached out to the emulator team and got this reply in case someone is looking for it.
This is how it looks now:
Thanks for sharing the docker steps for future users.