Azure / azure-cosmos-dotnet-v2

Contains samples and utilities relating to the Azure Cosmos DB .NET SDK
MIT License
577 stars 837 forks source link

emulator cannot start - Port 8081 is already in use #895

Closed vmachacek closed 2 years ago

vmachacek commented 2 years ago

Describe the bug sometimes emulator stops working and nothing helps to recover it except restart of Windows

To Reproduce usually when computer goes to sleep when it wakes up sometimes cosmos isn't working

Expected behavior when computer wakes up emulator to be working as expected

Actual behavior

when i run client app i get 408 error

Application startup exception: Microsoft.Azure.Cosmos.CosmosException : Response status code does not indicate success: RequestTimeout (408); Substatus: 0; ActivityId: 82fef008-5623-4870-b463-06b6c225b6a0; Reason: (GatewayStoreClient Request Timeout. Start Time UTC:3/25/2022 14:02:20; Total Duration:36089.92
31 Ms; Request Timeout 20000 Ms; Http Client Timeout:65000 Ms; Activity id: 82fef008-5623-4870-b463-06b6c225b6a0;);
 ---> System.Threading.Tasks.TaskCanceledException: The operation was canceled.
 ---> System.IO.IOException: Unable to read data from the transport connection: The I/O operation has been aborted because of either a thread exit or an application request..
 ---> System.Net.Sockets.SocketException (995): The I/O operation has been aborted because of either a thread exit or an application request.

When I open local web interface the address is responding but wont list any databases image

and there is "Querying databases" in progress spinner which never completes (not even roughly after 10 minutes, no timeout or error) image

when i try to run Microsoft.Azure.Cosmos.Emulator.exe /shutdown it completes without issue but does not kill it completely

when i run Get-Process -Id (Get-NetTCPConnection -LocalPort 8081).OwningProcess I get the system is running something on port 8081

image

when i run netsh http show servicestate view=requestq i get this part:

Request queue name: Request queue is unnamed.
    Version: 2.0
    State: Active
    Request queue 503 verbosity level: Basic
    Max requests: 1000
    Number of active processes attached: 1
    Processes:
        ID: 22636, image: C:\Program Files\Azure Cosmos DB Emulator\Packages\GatewayService\GatewayService.Code\Microsoft.Azure.Cosmos.GatewayService.exe
    URL groups:
    URL group ID: FE00000520000001
        State: Active
        Request queue name: Request queue is unnamed.
        Properties:
            Max bandwidth: inherited
            Max connections: inherited
            Timeouts:
                Timeout values inherited
            Number of registered URLs: 1
            Registered URLs:
                HTTPS://127.0.0.1:8081:127.0.0.1/
        Server session ID: FF00000510000003
            Version: 2.0
            State: Active
            Properties:
                Max bandwidth: 4294967295
                Timeouts:
                    Entity body timeout (secs): 120
                    Drain entity body timeout (secs): 120
                    Request queue timeout (secs): 120
                    Idle connection timeout (secs): 120
                    Header wait timeout (secs): 120
                    Minimum send rate (bytes/sec): 150

Environment summary

SDK Version: 6.0.101 OS Version (e.g. Windows, Linux, MacOSX): windows

vmachacek commented 2 years ago

i tried to run twice LODCTR /R as this page suggested but that wont fix my issue

vmachacek commented 2 years ago

i think i can attribute it to port clashing with some other app, i removed docker and so far so good..

lflewwelling commented 2 years ago

You can specify the port it runs on. Change shortcut to:

"C:\Program Files\Azure Cosmos DB Emulator\CosmosDB.Emulator.exe" /Port=8077