Azure / service-fabric-mesh-preview

Service Fabric Mesh is the Service Fabric's serverless offering to enable developers to deploy containerized applications without managing infrastructure. Service Fabric Mesh , aka project “SeaBreeze” is currently available in private preview. This repository will be used for tracking bugs/feature requests as GitHub issues and for maintaining the latest documentation.
MIT License
82 stars 12 forks source link

Cannot connect Cosmos DB emulator #342

Closed julipur closed 5 years ago

julipur commented 5 years ago

I have created a mesh application and trying to connect to local cosmos db emulator. I have seen other people have this issue and have tried everything in those other threads, but still no success.

I am starting the emulator on my host like so

CosmosDB.Emulator.exe /AllowNetworkAccess /NoFirewall /Key=C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==

Which allows to hit the emulator through the gateway ip of my servicefab_nat network.

The problem I am running into now from my application is this

Inner Exception 1: DocumentClientException: The authorization token is not valid at the current time. Please create another token and retry (token start time: Mon, 28 Jan 2019 17:41:32 GMT, token expiry time: Mon, 28 Jan 2019 17:56:32 GMT, current server time: Mon, 28 Jan 2019 14:41:32 GMT). ActivityId: 860a8cf7-9b02-4e64-a269-87cb54d4140d, Microsoft.Azure.Documents.Common/2.1.0.0

This is because the base image used by the project is this FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-1803 AS base

and I think this is set to Pacific standard time.

I've tried the following FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-1709 as base

The token error goes away but the call to cosmos "never" completes.

What do I need to do to successfully connect to cosmos db emulator.

jsmithtx commented 5 years ago

@julipur see #328 ... I had the same issue and my last post shows how I did it.

julipur commented 5 years ago

@jiffypopjr I have tried that and it didn't work for me. Even after importing the certificate, I was getting SSL error (I think because the certificate is for localhost) and I had to add extra code to ignore the SSL errors. After that code I started to get the timezone issue and there are others who are getting it too.

guibirow commented 5 years ago

Not sure if will help, but I would check if the certificate chain is trusted by the client. Because the certificate used by Cosmos is self-signed, just the host machine trust it.

This might give you some light: https://github.com/Azure/azure-cosmos-dotnet-v2/issues/284

julipur commented 5 years ago

Thanks @guibirow, that is exactly what I am doing to bypass the certificate (the thread you mentioned, I have gone through that). The problem I have mentioned in my issue here is the timezone issue. If I use the Dockerfile generated by ASF Mesh and try to connect to Cosmos in Azure, I get the same timezone issue. It only goes away if I change the base image to

FROM microsoft/dotnet:2.1-aspnetcore-runtime-nanoserver-sac2016 AS base

This allows me to work with Cosmos in Azure but locally, it just keeps spinning.

julipur commented 5 years ago

I'm closing this issue as I was able to connect to cosmos locally but in a very hacky way that I would not really use in my dev env.