# How to generate id.jwt in Ziti console for C# sample - weather app

**URL:** <https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913>\
**Category:** sdk-csharp\
**Created:** [December 2, 2022, 12:31pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913 "2022-12-02T12:31:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![RS\_MOB](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@RS\_MOB](https://openziti.discourse.group/u/RS_MOB)\
**Post date:** [December 2, 2022, 12:31pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/1 "2022-12-02T12:31:22Z")

</div>

Hi,

We have downloaded the sample weather app from below path,

> **[ziti-sdk-csharp/Samples at main · openziti/ziti-sdk-csharp](https://github.com/openziti/ziti-sdk-csharp/tree/main/Samples)**
>
> main/Samples

While running the sample app, we are facing the below error.  
**Sample failed to execute: Could not find a part of the path ‘c:\temp\id.json’**

The same error has been attached as screenshot for your reference.

 ![image](https://global.discourse-cdn.com/free1/uploads/netfoundry/original/1X/ecc8fa185361bcf42a9fed2c53ee31a2666fc635.png)

Kindly let us know how to create id.json or id.jwt in ziti console for weather app to check this sample.

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [December 2, 2022, 2:14pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/2 "2022-12-02T14:14:18Z")

</div>

Hi @RS_MOB, welcome to the community!

I just went and filed an issue to document this. Thanks for bringing it up. [Update Samples and provide instructions · Issue #40 · openziti/ziti-sdk-csharp · GitHub](https://github.com/openziti/ziti-sdk-csharp/issues/40)

The basic flow is the same as any identity. I'll assume you have already installed an OpenZiti network using [one of the quickstarts](https://openziti.github.io/docs/quickstarts/network/#which-network-option-sounds-right-for-you). You'll need that first, of course. The instructions I provide below will assume you have a quickstart network deployed.

Once you have your network established, you need a service defined and accessible. Here's how you do that from start to finish. I also made an 8 minute video you can watch if you want to watch me do it

[![](https://global.discourse-cdn.com/free1/uploads/netfoundry/original/1X/4ffbcbeda89407f3c9d9c0fcda20c52b87c69cf7.jpeg "Discourse 913 - csharp weather demo") ](https://www.youtube.com/watch?v=dxHcpzENUP0)

## Steps to Run Weather Sample

### Make the Offload Side

This sample expects to use a router as the offload point for traffic. To setup the offload, make a `host.v1` config to be used in your service that points to the actual target: in this case, `wttr.in`. Do that with:

```auto
ziti edge create config weather-svc.host.v1 host.v1 '{"protocol":"tcp", "address":"wttr.in","port":80}'

```

Find the name of your edge router identity, mine is: `ip-172-31-45-134-edge-router`. Use that identity and assign the attribute of "csharp.offload". This attribute will be used below when authorizing the identity to offload the data from the overlay network.

```auto
ziti edge update identity ip-172-31-45-134-edge-router -a "csharp.offload"

```

### Make the Service

Now use the config to make a service, instructing OpenZiti to offloading the connection. Also use an attribute named `#csharp.offload` for the service so if there are others, they will all get authorized (see below)

```auto
ziti edge create service weather-svc --configs weather-svc.host.v1 -a "csharp.sample"

```

### Authorize the Offload Identity

The offload identity needs to be authorized to 'bind' or 'host' the service. Here we're using a router with tunneling enabled and we've used a `host.v1` config so that we can offload from the overlay to some otehr location. Authorize the offload endpoint now:

```auto
ziti edge create service-policy csharp.demos.bind Bind --service-roles '#csharp.sample' --identity-roles '#csharp.offload'

```

### Create the Identity

**Here's where you'll make that identity you are looking for.** Make the identity, use an attribute called '`#csharp.demo'` for easy authorization of other services for this identity.

```auto
ziti edge create identity user csharp.demo -o csharp.demo.jwt -a "csharp.demo"

```

For now, use the `ziti` cli to enroll the identity, notice that here **the output file is put into c:\temp\id.json** (or wherever you want to put it, you can change the path of course):

```auto
ziti edge enroll -j c:\temp\csharp.demo.jwt -o c:\temp\id.json

```

Output should look like:

```auto
INFO generating 4096 bit RSA key
INFO enrolled successfully. identity file written to: c:\temp\id.json

```

### Authorize the Identity

Finally authorize the identity to be able to 'dial' or access the service:

```auto
ziti edge create service-policy csharp.demos.dial Dial --service-roles '#csharp.sample' --identity-roles '#csharp.demo'

```

### Test It Out

```auto
git clone git@github.com:openziti/ziti-sdk-csharp.git
cd ziti-sdk-csharp/Samples
dotnet run Console.csproj weather C:\temp\csharp\ziti-sdk-csharp\csharp.json

```

---

<div class="post-metadata">

**Author:** ![ac\_225](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@ac\_225](https://openziti.discourse.group/u/ac_225)\
**Post date:** [December 2, 2022, 3:49pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/3 "2022-12-02T15:49:23Z")

</div>

@TheLumberjack , Thanks for posting the video. I’m in the same boat at the moment, trying to get the C# example working locally. I’m very new to OpenZiti and still getting familiar with the terminologies and the concept.

Just wanted to clarify a few things:  
In this demo sample, the C# app is connecting to wttr.in via the OpenZiti overlay. Wttr.in is a website hosted on port 80, open on the internet. We are embedding Zero Trust in the demo application via the SDK, and so on the other side we are connecting to a edge router that will offload the traffic to another location. Why do we need to route via the overlay, when wttr.in is open on the internet?

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [December 2, 2022, 5:42pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/4 "2022-12-02T17:42:15Z")

</div>

Hi @ac_225, welcome to the community!

You are **spot on**. Accessing a PUBLICALLY available service on the open internet just **seems silly**!!! Totally agree.

However, this is just a demonstration of how to use the sdk on the client-side. Where the traffic terminates, on the far side, whether it’s in another identity (truly application embedded zero trust and the best you can get), or to a private underlay service (like Jenkins, or whatever), or to a public service - none of those things matter to this _particular_ sample.

What does matter though is the overall burden that the sample runner needs to understand. By using some public service like this, you can learn what it looks like on the client side without having to go install a web server on some private network.

If you have that situation already setup - wonderful! Just change wttr.in to whatever server/port you’re looking to access.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![ac\_225](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@ac\_225](https://openziti.discourse.group/u/ac_225)\
**Post date:** [December 2, 2022, 6:38pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/5 "2022-12-02T18:38:42Z")

</div>

Thank you @TheLumberjack.

So I have the network overlay created locally and I have a simple Hello World azure function that i’m ready to Zitify. I’ll do this locally first, and then deploy it to Azure. I’m going to use the .NET SDK. I may need help building the docs so I can see how to use the SDK. In the weather example, looks like there are a couple of delegates that have been implemented. I’m trying to figure out the bare minimum (steps, delegates, events) I’m going to need to use the .NET SDK. Any help in this area is highly appreciated.

Thanks!

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [December 2, 2022, 6:53pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/6 "2022-12-02T18:53:33Z")

</div>

That all sounds great. With the holidays last week and with me taking ill this week, my throughput has been significantly degraded. I am still trying to get the latest and greatest SDK deployed, but I haven’t gotten it out yet for ☝ reasons.

I’m happy and eager to help out however I can. There’s a “hosted example” you can look at too and start learning how that works. I didn’t get that documented yet - but that’s on my plate.

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [December 2, 2022, 7:05pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/7 "2022-12-02T19:05:30Z")

</div>

Oh also, the docs are available by going to the doc site [https://openziti.github.io](https://openziti.github.io), clicking on APIs on the top, then clicking on OpenZiti .NET SDK on the left…

 ![image](https://global.discourse-cdn.com/free1/uploads/netfoundry/original/1X/6113daa7b50eec4c21efa78059d62caf0a2d8471.png)

That’ll get you to the current doc site which is at [OpenZiti .NET SDK](https://openziti.github.io/api/csharp/) (or [Namespace OpenZiti](https://openziti.github.io/api/csharp/api/dotnet/OpenZiti.html))

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [December 6, 2022, 12:30am UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/8 "2022-12-06T00:30:04Z")

</div>

Hi @RS_MOB and @ac_225,

I’ve published a new (and renamed) version of the [dotnet sdk repository](https://github.com/openziti/ziti-sdk-csharp). This version of the SDK is now targeting .net6.0 and no longer .netstandard2.1 to keep up with the times.

Along with that, the package was renamed as well. It’s no longer called `Ziti.NET.Standard`, it’s now called just `OpenZiti.NET` (and the transitive `OpenZiti.NET.standard`). The latest version is: `0.8.339.42160`

You should now be able to check out the repo, cd to `Samples` and `dotnet run` the samples. To run the `hosted` example you’ll want to build the executable and run that instead of `dotnet run` because you will probably want to run both `hosted` and `hosted-client` (for the full sample).

I created powershell scripts which use the `ziti` CLI to bootstrap an OpenZiti overlay network, if you have access to the CLI. If you don’t, you’ll need to translate the `ziti` commands to the UI you’re using.

The samples are much simpler and shorter. Please review. This is a work in progress. The APIs shouldn’t change much but they might need to get rearranged and refactored. If that happens I’ll bump the version to 0.9.x to indicate the change.

If you take a look and have questions, please follow up here and we’ll iterate until things work. I’ve tested the code on linux and windows so far.

---

<div class="post-metadata">

**Author:** ![RS\_MOB](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@RS\_MOB](https://openziti.discourse.group/u/RS_MOB)\
**Post date:** [December 13, 2022, 5:51am UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/9 "2022-12-13T05:51:22Z")

</div>

Hi @TheLumberjack Thank you for your valuable inputs.

We have completed enrollment steps and got the required JSON file. With the JSON file we are trying to get the weather details but facing location violation exception.

 ![Error](https://global.discourse-cdn.com/free1/uploads/netfoundry/original/1X/afcb886e51b7f1930819f95050d06a86591297f6.png)

so please let us know whether the location will be taken up from device or need to specify somewhere in code.

---

<div class="post-metadata">

**Author:** ![ac\_225](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@ac\_225](https://openziti.discourse.group/u/ac_225)\
**Post date:** [December 13, 2022, 6:36am UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/10 "2022-12-13T06:36:10Z")

</div>

Hello! I have the latest updated C# SDK sample code and I’m trying to get the weather example to work locally. I ran through the steps to set up the service, service-policy, identity creation and enrollment. It seems to run fine until the part where it’s making the HTTP call and then its throwing an error - Connection is closed.

 ![Ziti_connection_is_closed_error_https](https://global.discourse-cdn.com/free1/uploads/netfoundry/original/1X/ffb81266ccb2af011d29b2a5ee0cd5e1dad823d3.jpeg)  
 ![Ziti_conn_error](https://global.discourse-cdn.com/free1/uploads/netfoundry/original/1X/78109e9fa1602ddccaa6e7175054531e4b20aa35.jpeg)

Please let me know If I missed any steps or how should I debug further.

---

<div class="post-metadata">

**Author:** ![RS\_MOB](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@RS\_MOB](https://openziti.discourse.group/u/RS_MOB)\
**Post date:** [December 13, 2022, 10:22am UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/11 "2022-12-13T10:22:39Z")

</div>

Hi, Thanks for you update.

Actually we are working with previous version of C# sample and that is compatible for our application.  
Is it possible to check and give us inputs in the previous sample version?

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [December 13, 2022, 11:57am UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/12 "2022-12-13T11:57:06Z")

</div>

> [@RS\_MOB](#):
>
> With the JSON file we are trying to get the weather details but facing location violation exception.

This always means you're somehow activating the x86 code from an x64 process, or activating the x64 code from an x86 process. Are you running with "Any CPU"? I think I might have experienced this issue when running in my visual studio debugger but it only happened one time. You don't have the project online at all for me to look at and try do you? I also notice that this is with the older code base. Do you need to use the older code? The newest library was updated with all the linux+mac binaries and should have this problem sorted.

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [December 13, 2022, 12:02pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/13 "2022-12-13T12:02:50Z")

</div>

> [@ac\_225](#):
>
> Please let me know If I missed any steps or how should I debug further.

Can you uncomment the native debugging lines to get the native logs:

```auto
//API.NativeLogger = API.DefaultConsoleLoggerFunction;
//API.InitializeZiti(OpenZiti.Logging.ZitiLogLevel.DEBUG);

```

That will output extra logging from the native debugger to your console for view. There might be some useful information in there. My guess is that the service is somehow setup incorrectly or that a router is offline. Get the DEBUG logs and let me look at that please?

---

<div class="post-metadata">

**Author:** ![ac\_225](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@ac\_225](https://openziti.discourse.group/u/ac_225)\
**Post date:** [December 13, 2022, 5:11pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/14 "2022-12-13T17:11:12Z")

</div>

Used the express install to create a local network. Here are controller, edge-router and application logs:

Controller logs:  
[76013.332] ERROR channel/v2.(\*classicListener).acceptConnection.func1 [tls:0.0.0.0:6262]: connection handler error for [tls:127.0.0.1:50896] (unknown/unenrolled router, routerId: q0dI7hhV6C)  
[76014.668] ERROR fabric/controller/handler\_ctrl.(\*ConnectHandler).HandleConnection: {routerId=[OFQ2-ZurM]} unknown/unenrolled router  
[76014.668] ERROR channel/v2.(\*classicListener).acceptConnection.func1 [tls:0.0.0.0:6262]: connection handler error for [tls:127.0.0.1:50901] (unknown/unenrolled router, routerId: OFQ2-ZurM)  
[76014.775] ERROR fabric/controller/handler\_ctrl.(\*ConnectHandler).HandleConnection: {routerId=[q0dI7hhV6C]} unknown/unenrolled router  
[76014.776] ERROR channel/v2.(\*classicListener).acceptConnection.func1 [tls:0.0.0.0:6262]: connection handler error for [tls:127.0.0.1:50902] (unknown/unenrolled router, routerId: q0dI7hhV6C)

Edge-router logs:  
[76191.800] INFO channel/v2.getRetryVersionFor: defaulting to version 2  
[76191.800] ERROR channel/v2.(\*reconnectingDialer).Reconnect [u{reconnecting}-\>i{l8E6} @tls:ACHITRAPUR-LT:6262]: hello attempt [#14450] failed (EOF)  
[76192.442] ERROR channel/v2.(\*heartbeater).sendHeartbeat: {error=[timeout waiting for message reply: context deadline exceeded] channelId=[ch{ctrl}-\>u{reconnecting}-\>i{l8E6}]} failed to send heartbeat  
[76193.443] ERROR channel/v2.(\*heartbeater).sendHeartbeat: {error=[timeout waiting for message reply: context deadline exceeded] channelId=[ch{ctrl}-\>u{reconnecting}-\>i{l8E6}]} failed to send heartbeat  
[76194.443] ERROR channel/v2.(\*heartbeater).sendHeartbeat: {error=[timeout waiting for message reply: context deadline exceeded] channelId=[ch{ctrl}-\>u{reconnecting}-\>i{l8E6}]} failed to send heartbeat  
[76195.445] ERROR channel/v2.(\*heartbeater).sendHeartbeat: {error=[timeout waiting for message reply: context deadline exceeded] channelId=[ch{ctrl}-\>u{reconnecting}-\>i{l8E6}]} failed to send heartbeat  
[76196.447] ERROR channel/v2.(\*heartbeater).sendHeartbeat: {error=[timeout waiting for message reply: context deadline exceeded] channelId=[ch{ctrl}-\>u{reconnecting}-\>i{l8E6}]} failed to send heartbeat  
[76196.823] INFO channel/v2.getRetryVersionFor: defaulting to version 2  
[76196.823] ERROR channel/v2.(\*reconnectingDialer).Reconnect [u{reconnecting}-\>i{l8E6} @tls:ACHITRAPUR-LT:6262]: hello attempt [#14451] failed (EOF)  
[76197.449] ERROR channel/v2.(\*heartbeater).sendHeartbeat: {error=[timeout waiting for message reply: context deadline exceeded] channelId=[ch{ctrl}-\>u{reconnecting}-\>i{l8E6}]} failed to send heartbeat  
[76198.449] ERROR channel/v2.(\*heartbeater).sendHeartbeat: {channelId=[ch{ctrl}-\>u{reconnecting}-\>i{l8E6}] error=[timeout waiting for message reply: context deadline exceeded]} failed to send heartbeat  
[76199.451] ERROR channel/v2.(\*heartbeater).sendHeartbeat: {error=[timeout waiting for message reply: context deadline exceeded] channelId=[ch{ctrl}-\>u{reconnecting}-\>i{l8E6}]} failed to send heartbeat

Weather sample logs:  
Pasting logs from the enrollement step:  
SDKd: ziti-sdk:ziti\_enroll.c:163 well\_known\_certs\_cb() CA PEM len = 12643  
SDKi: ziti-sdk:ziti\_ctrl.c:407 ziti\_ctrl\_init() ctrl[ACHITRAPUR-LT] ziti controller client initialized  
SDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed POST[/enroll?method=ott&token=70ec2537-6ebb-4de0-8f3f-4740e2519c71] in 0.031 s  
SDKd: ziti-sdk:ziti\_enroll.c:239 enroll\_cb() successfully enrolled with controller [https://ACHITRAPUR-LT:1280](https://ACHITRAPUR-LT:1280)  
Strong identity enrolled successfully. File saved to: C:\Repos\GitHub\Samples\bin\Debug\net6.0/weather.demo.json  
SDKd: ziti-sdk:zitilib.c:303 load\_ziti\_ctx() loading identity from C:\Repos\GitHub\Samples\bin\Debug\net6.0/weather.demo.json  
SDKi: ziti\_log\_set\_level set log level: root=4  
SDKi: ziti-sdk:ziti.c:428 ziti\_init\_async() ztx[0] Ziti C SDK version 0.30.8-132 @ecfee7b(HEAD) starting at (2022-12-13T16:50:22.588)  
SDKi: ziti-sdk:ziti.c:429 ziti\_init\_async() ztx[0] using uv\_mbed[v0.14.11], tls[mbed TLS 3.2.1]  
SDKi: ziti-sdk:ziti.c:430 ziti\_init\_async() ztx[0] Loading from config[C:\Repos\GitHub\Samples\bin\Debug\net6.0/weather.demo.json] controller[[https://ACHITRAPUR-LT:1280](https://ACHITRAPUR-LT:1280)]  
SDKi: ziti-sdk:ziti\_ctrl.c:407 ziti\_ctrl\_init() ctrl[ACHITRAPUR-LT] ziti controller client initialized  
SDKd: ziti-sdk:ziti.c:452 ziti\_init\_async() ztx[0] using metrics interval: 0  
SDKd: ziti-sdk:ziti.c:259 ziti\_set\_unauthenticated() ztx[0] setting api\_session\_state[0] to 0  
SDKd: ziti-sdk:ziti\_ctrl.c:244 ziti\_ctrl\_clear\_api\_session() ctrl[ACHITRAPUR-LT] clearing api session token for ziti\_controller  
SDKd: ziti-sdk:ziti.c:919 ziti\_re\_auth() ztx[0] re-auth executing, transitioning to unauthenticated  
SDKd: ziti-sdk:ziti.c:259 ziti\_set\_unauthenticated() ztx[0] setting api\_session\_state[0] to 0  
SDKd: ziti-sdk:ziti\_ctrl.c:244 ziti\_ctrl\_clear\_api\_session() ctrl[ACHITRAPUR-LT] clearing api session token for ziti\_controller  
SDKd: ziti-sdk:ziti.c:290 is\_api\_session\_expired() ztx[0] is\_api\_session\_expired[TRUE] - api\_session is null  
SDKi: ziti-sdk:ziti.c:867 ziti\_re\_auth\_with\_cb() ztx[0] starting to re-auth with ctlr[[https://ACHITRAPUR-LT:1280](https://ACHITRAPUR-LT:1280)] api\_session\_status[0] api\_session\_expired[TRUE]  
SDKd: ziti-sdk:ziti.c:252 ziti\_set\_auth\_started() ztx[0] setting api\_session\_state[0] to 1  
SDKd: ziti-sdk:ziti.c:324 ziti\_stop\_api\_session\_refresh() ztx[0] ziti\_stop\_api\_session\_refresh: stopping api session refresh  
SDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed GET[/version] in 0.025 s  
SDKi: ziti-sdk:ziti.c:1533 version\_cb() ztx[0] connected to controller [https://ACHITRAPUR-LT:1280](https://ACHITRAPUR-LT:1280) version v0.26.11(807dd591b1f5 2022-11-10T14:53:29Z)  
SDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed POST[/authenticate?method=cert] in 0.043 sSDKd: ziti-sdk:ziti\_ctrl.c:257 ctrl\_login\_cb() ctrl[ACHITRAPUR-LT] authenticated successfully session[clbmgmbe41mbggvs1l202806w]  
SDKd: ziti-sdk:ziti.c:1449 api\_session\_cb() ztx[0] logged in successfully =\> api\_session[clbmgmbe41mbggvs1l202806w]  
SDKd: ziti-sdk:ziti.c:1399 ziti\_set\_api\_session() ztx[0] ziti api session expires in 1800 seconds  
SDKi: ziti-sdk:ziti.c:1423 ziti\_set\_api\_session() ztx[0] api session set, setting api\_session\_timer to 1740s  
SDKd: ziti-sdk:ziti.c:329 ziti\_schedule\_api\_session\_refresh() ztx[0] ziti\_schedule\_api\_session\_refresh: scheduling api session refresh: 1740000ms  
SDKd: ziti-sdk:ziti.c:284 ziti\_set\_fully\_authenticated() ztx[0] setting api\_session\_state[1] to 3  
SDKd: ziti-sdk:ziti.c:284 ziti\_set\_fully\_authenticated() ztx[0] setting api\_session\_state[3] to 3  
SDKd: ziti-sdk:ziti\_ctrl.c:774 ctrl\_paging\_req() ctrl[ACHITRAPUR-LT] starting paging request GET[/current-identity/edge-routers]  
SDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed GET[/current-identity] in 0.003 s  
SDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed GET[/current-identity] in 0.003 s  
SDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed GET[/current-identity/edge-routers?limit=25&offset=0] in 0.006 s  
SDKd: ziti-sdk:ziti\_ctrl.c:340 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] received 1/1 for paging request GET[/current-identity/edge-routers]  
SDKd: ziti-sdk:ziti\_ctrl.c:352 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed paging request GET[/current-identity/edge-routers] in 0.006 s  
SDKi: ziti-sdk:channel.c:231 new\_ziti\_channel() ch[0] (ACHITRAPUR-LT-edge-router@tls://ACHITRAPUR-LT:3022) new channel for ztx[0] identity[weather.demo]  
SDKi: ziti-sdk:channel.c:742 reconnect\_channel() ch[0] reconnecting NOW  
SDKd: ziti-sdk:channel.c:713 reconnect\_cb() ch[0] connecting to ACHITRAPUR-LT:3022  
SDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed GET[/current-api-session/service-updates] in 0.042 s  
SDKd: ziti-sdk:ziti\_ctrl.c:774 ctrl\_paging\_req() ctrl[ACHITRAPUR-LT] starting paging request GET[/services]  
SDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed GET[/services?limit=25&offset=0] in 0.003 s  
SDKd: ziti-sdk:ziti\_ctrl.c:340 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] received 1/1 for paging request GET[/services]  
SDKd: ziti-sdk:ziti\_ctrl.c:352 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed paging request GET[/services] in 0.007 s  
SDKd: ziti-sdk:ziti.c:1146 update\_services() ztx[0] sending service event 1 added, 0 removed, 0 changed  
SDKd: ziti-sdk:channel.c:861 on\_channel\_connect\_internal() ch[0] connected  
SDKi: ziti-sdk:channel.c:640 hello\_reply\_cb() ch[0] connected. EdgeRouter version: v0.26.11|807dd591b1f5|2022-11-10T14:53:29Z|linux|amd64  
SDKi: ziti-sdk:posture.c:204 ziti\_send\_posture\_data() ztx[0] first run or potential controller restart detected  
SDKd: ziti-sdk:posture.c:211 ziti\_send\_posture\_data() ztx[0] posture checks must\_send set to TRUE, new\_session\_id[TRUE], must\_send\_every\_time[TRUE], new\_controller\_instance[TRUE]  
Request:  
Method: GET, RequestUri: ‘[https://wttr.in/](https://wttr.in/)’, Version: 1.1, Content: , Headers:  
{  
User-Agent: curl/7.59.0  
}

SDKd: ziti-sdk:zitilib.c:634 do\_ziti\_connect() connecting fd[1632] to (null):0  
SDKd: ziti-sdk:zitilib.c:689 do\_ziti\_connect() connecting fd[1632] to service[weather-svc]  
SDKd: ziti-sdk:posture.c:211 ziti\_send\_posture\_data() ztx[0] posture checks must\_send set to TRUE, new\_session\_id[FALSE], must\_send\_every\_time[TRUE], new\_controller\_instance[FALSE]  
SDKd: ziti-sdk:connect.c:518 process\_connect() conn[0.0/Connecting] requesting ‘Dial’ session for service[weather-svc]  
SDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed POST[/sessions] in 0.013 s  
SDKd: ziti-sdk:connect.c:480 connect\_get\_net\_session\_cb() conn[0.0/Connecting] got session[clbmgmfud1mbogvs120lnq0so] for service[weather-svc]  
SDKd: ziti-sdk:posture.c:211 ziti\_send\_posture\_data() ztx[0] posture checks must\_send set to TRUE, new\_session\_id[FALSE], must\_send\_every\_time[TRUE], new\_controller\_instance[FALSE]  
SDKd: ziti-sdk:connect.c:528 process\_connect() conn[0.0/Connecting] starting Dial connection for service[weather-svc] with session[clbmgmfud1mbogvs120lnq0so]  
SDKd: ziti-sdk:connect.c:411 ziti\_connect() conn[0.0/Connecting] selected ch[ACHITRAPUR-LT-edge-router@tls://ACHITRAPUR-LT:3022] for best latency(6 ms)  
SDKd: ziti-sdk:connect.c:299 on\_channel\_connected() conn[0.0/Connecting] selected ch[ACHITRAPUR-LT-edge-router@tls://ACHITRAPUR-LT:3022] status[0]  
SDKd: ziti-sdk:channel.c:211 ziti\_channel\_add\_receiver() ch[0] added receiver[0]  
SDKi: ziti-sdk:channel.c:837 on\_channel\_data() ch[0] channel was closed [-4095/end of file]  
SDKe: ziti-sdk:connect.c:926 connect\_reply\_cb() conn[0.0/Connecting] failed to connect [-20/Unknown system error -20]  
SDKw: ziti-sdk:zitilib.c:591 on\_ziti\_connect() failed to establish ziti connection: -23(connection is closed)  
SDKd: ziti-sdk:zitilib.c:565 on\_bridge\_close() closed conn for socket(1632)  
SDKd: ziti-sdk:connect.c:1404 queue\_edge\_message() conn[0.0/Closed] closed due to err[-20](Connection to edge router terminated)  
SDKw: ziti-sdk:connect.c:1417 queue\_edge\_message() conn[0.0/Closed] disconnecting from state[9]  
SDKd: ziti-sdk:ziti.c:334 ziti\_force\_api\_session\_refresh() ztx[0] forcing session refresh  
SDKd: ziti-sdk:ziti.c:329 ziti\_schedule\_api\_session\_refresh() ztx[0] ziti\_schedule\_api\_session\_refresh: scheduling api session refresh: 0ms  
SDKi: ziti-sdk:channel.c:739 reconnect\_channel() ch[0] reconnecting in 8863 ms (attempt = 1)  
SDKi: ziti-sdk:channel.c:837 on\_channel\_data() ch[0] channel was closed [-4095/end of file]  
SDKd: ziti-sdk:ziti.c:334 ziti\_force\_api\_session\_refresh() ztx[0] forcing session refresh  
SDKd: ziti-sdk:ziti.c:329 ziti\_schedule\_api\_session\_refresh() ztx[0] ziti\_schedule\_api\_session\_refresh: scheduling api session refresh: 0ms  
SDKi: ziti-sdk:channel.c:739 reconnect\_channel() ch[0] reconnecting in 14292 ms (attempt = 2)  
SDKd: ziti-sdk:ziti.c:840 api\_session\_refresh() ztx[0] api\_session\_refresh running  
SDKd: ziti-sdk:ziti.c:302 is\_api\_session\_expired() ztx[0] is\_api\_session\_expired[FALSE] - default case  
SDKd: ziti-sdk:ziti.c:855 api\_session\_refresh() ztx[0] api\_session\_refresh refreshing api session by querying controllerSDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed GET[/current-api-session] in 0.075 s  
SDKd: ziti-sdk:ziti\_ctrl.c:257 ctrl\_login\_cb() ctrl[ACHITRAPUR-LT] authenticated successfully session[clbmgmbe41mbggvs1l202806w]  
SDKd: ziti-sdk:ziti.c:1449 api\_session\_cb() ztx[0] refreshed successfully =\> api\_session[clbmgmbe41mbggvs1l202806w]  
SDKd: ziti-sdk:ziti.c:1399 ziti\_set\_api\_session() ztx[0] ziti api session expires in 1794 seconds  
SDKi: ziti-sdk:ziti.c:1423 ziti\_set\_api\_session() ztx[0] api session set, setting api\_session\_timer to 1740s  
SDKd: ziti-sdk:ziti.c:329 ziti\_schedule\_api\_session\_refresh() ztx[0] ziti\_schedule\_api\_session\_refresh: scheduling api session refresh: 1740000ms  
SDKd: ziti-sdk:ziti.c:284 ziti\_set\_fully\_authenticated() ztx[0] setting api\_session\_state[3] to 3  
SDKd: ziti-sdk:ziti.c:284 ziti\_set\_fully\_authenticated() ztx[0] setting api\_session\_state[3] to 3  
SDKd: ziti-sdk:ziti\_ctrl.c:774 ctrl\_paging\_req() ctrl[ACHITRAPUR-LT] starting paging request GET[/current-identity/edge-routers]

SDKd: ziti-sdk:channel.c:713 reconnect\_cb() ch[0] connecting to ACHITRAPUR-LT:3022  
SDKd: ziti-sdk:posture.c:211 ziti\_send\_posture\_data() ztx[0] posture checks must\_send set to TRUE, new\_session\_id[FALSE], must\_send\_every\_time[TRUE], new\_controller\_instance[FALSE]  
Sample failed to execute: One or more errors occurred. (connection is closed (wttr.in:443))

SDKd: ziti-sdk:channel.c:861 on\_channel\_connect\_internal() ch[0] connected  
SDKi: ziti-sdk:channel.c:640 hello\_reply\_cb() ch[0] connected. EdgeRouter version: v0.26.11|807dd591b1f5|2022-11-10T14:53:29Z|linux|amd64  
SDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed GET[/current-identity] in 45.061 s  
SDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed GET[/current-identity] in 45.059 s  
SDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed GET[/current-identity/edge-routers?limit=25&offset=0] in 0.162 s  
SDKd: ziti-sdk:ziti\_ctrl.c:340 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] received 1/1 for paging request GET[/current-identity/edge-routers]  
SDKd: ziti-sdk:ziti\_ctrl.c:352 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed paging request GET[/current-identity/edge-routers] in 45.061 s  
SDKd: ziti-sdk:channel.c:276 ziti\_channel\_connect() ztx[0] existing ch0 found for ingress[tls://ACHITRAPUR-LT:3022]  
SDKd: ziti-sdk:ziti\_ctrl.c:324 ctrl\_body\_cb() ctrl[ACHITRAPUR-LT] completed GET[/current-api-session/service-updates] in 0.157 s  
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)  
at System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task`1.get\_Result()  
at OpenZiti.Samples.Weather.Run(String args) in C:\Repos\GitHub\Samples\Weather.cs:line 41  
at OpenZiti.Samples.Program.Main(String args) in C:\Repos\GitHub\Samples\Program.cs:line 26

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [December 13, 2022, 6:21pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/15 "2022-12-13T18:21:59Z")

</div>

Split this topic on December 13, 2022, 6:21pm UTC

A post was split to a new topic: [Using CloudZiti with the dotnet SDK](https://openziti.discourse.group/t/using-cloudziti-with-the-dotnet-sdk/937)

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [December 13, 2022, 6:35pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/16 "2022-12-13T18:35:47Z")

</div>

I see a bug in the setup script. See [ziti-sdk-csharp/weather.ps1 at main · openziti/ziti-sdk-csharp · GitHub](https://github.com/openziti/ziti-sdk-csharp/blob/main/Samples/setup-scripts/weather.ps1#L89)

There’s no space between the closing quote and the double hyphen. That might be the cause:

```auto
ziti edge create service 'weather-svc'--configs ..... (no space)

```

should be

```auto
ziti edge create service 'weather-svc' --configs ..... (has the space)

```

I’ll push a patch for that shortly, I think that’s what happened. I’ll try to replicate that as well. thx

---

<div class="post-metadata">

**Author:** ![RS\_MOB](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@RS\_MOB](https://openziti.discourse.group/u/RS_MOB)\
**Post date:** [January 20, 2023, 10:01am UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/17 "2023-01-20T10:01:45Z")

</div>

Hi @TheLumberjack, Thanks for your updates.

We have created Endpoint, Service and AppWan for Weather sample in Ziti Console using our NetFoundry account. We followed the same steps as like the below community discussion.

> [@Using CloudZiti with the dotnet SDK](https://openziti.discourse.group/t/using-cloudziti-with-the-dotnet-sdk/937/4):
>
> I added a community post over at [Using CloudZiti with the dotnet SDK - How things work - NetFoundry Community Support](https://community.netfoundry.io/t/using-cloudziti-with-the-dotnet-sdk/172) but i’ll recap the post here too. Here’s how you would do that with CloudZiti: Obtain a CloudZiti/NetFoundry Console login and login Create an endpoint named “weather.demo” (no attributes needed) : [image] download the jwt to your local computer and put it into the folder of your choice. I’ll put it into my WSL instance at /tmp/weather.demo but you could put it anywher…

Post creation of above steps, downloaded the jwt file from ziti console and completed the enrollment process using the sample app and got the respective Json file. But when we try to fetch the weather details by passing Json as input, facing **'Location access violation'** error. PFA.

 ![Error](https://global.discourse-cdn.com/free1/uploads/netfoundry/original/1X/bcb0e0a56768023802349663d3e3a28bc568be39.png)  
Where we need to set the location either it picks automatically from device or need to set it somewhere in project?

PFB the sample Weather project we tried to get Weather details.  
[https://drive.google.com/file/d/1QxNZyK\_QrgyIb9EDC9ls2A3pyA9Cb9Gf/view?usp=sharing](https://apc01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fdrive.google.com%2Ffile%2Fd%2F1QxNZyK_QrgyIb9EDC9ls2A3pyA9Cb9Gf%2Fview%3Fusp%3Dsharing&data=05%7C01%7CMohanraj.N%40ramco.com%7C92659861b46543caef3408dafac124ab%7C75f8ca7fffca4bf8a4d28a83d0d6e896%7C0%7C0%7C638098004736915322%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=CFYddy%2FbYgdOGCB%2BO4DLPjv4YTE4EaH5Nb7%2FHMfK4Sw%3D&reserved=0)

This sample project has older .NET version of SDK because that is compatible to our application.

Kindly help us resolving Access location violation issue.

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [January 20, 2023, 1:12pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/18 "2023-01-20T13:12:59Z")

</div>

Hi @RS_MOB, the “Access violation”, from my experience, has always been a problem of the launch arch not matching the library. Native libs and dotnet can sometimes be a little tricky. Previous SDKs might have had issues determining exactly which native arch to launch…

Also, thanks for the project. I downloaded it and opened/ran the Ziti.Samples.sln just as it came from that zip file. However, it launched under “Any CPU” (the only configuration in the solution) fine. I added an x64 and an x86 and both of those launched fine too, which confused me. I expected to see the access violation you referenced with one or the other.

Do you have any more details you can share about how you launched the app? Any parameters, run config etc? I can’t trigger the problem you’re seeing yet… 😕

---

<div class="post-metadata">

**Author:** ![TheLumberjack](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/thelumberjack/32/113_2.png) [@TheLumberjack](https://openziti.discourse.group/u/TheLumberjack)\
**Post date:** [January 20, 2023, 1:16pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/19 "2023-01-20T13:16:35Z")

</div>

Also, the older SDK functions/API was replaced with the “Ziti\_lib” functionality from the CSDK. I’m concerned for you that using the older code will make a bit of work when you upgrade later on. Please do be aware of that. If there are functions in the older library that you need/want, I’d like to hear that feedback too as it’ll help us determine what functionality people are wanting/using.

I’m also interested in your dotnet version – what are you running? Is it .NET Framework 4.x? or .netcore 3?

---

<div class="post-metadata">

**Author:** ![RS\_MOB](https://avatars.discourse-cdn.com/v4/letter/r/ac8455/32.png) [@RS\_MOB](https://openziti.discourse.group/u/RS_MOB)\
**Post date:** [March 3, 2023, 12:48pm UTC](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913/20 "2023-03-03T12:48:02Z")

</div>

Hi @TheLumberjack Thanks for the update.

We are still facing the same Access violation issue during runtime of C# console application.

Since eventually we need this SDK to be implemented in Xamarin based Mobile application which is on C#. So we tried sample mobile app with **Ziti.NET.Standard nuget versions** from **0.7.112.23262** till **0.8.300.268** 13 to get Weather details but facing below exception during runtime,

{System.TypeInitializationException: The type initializer for ‘OpenZiti.API’ threw an exception. —\> System.TypeInitializationException: The type initializer for ‘OpenZiti.UVLoop’ threw an exception. —\> System.DllNotFoundException: ziti4dotnet assembly: type: member:(null)  
at (wrapper managed-to-native) OpenZiti.Native.API.z4d\_default\_loop()  
at OpenZiti.UVLoop…cctor () [0x00000] in D:\a\ziti-sdk-csharp\ziti-sdk-csharp\Ziti.NET.Standard\src\OpenZiti\UVLoop.cs:21  
— End of inner exception stack trace —  
at OpenZiti.API…cctor () [0x0001d] in D:\a\ziti-sdk-csharp\ziti-sdk-csharp\Ziti.NET.Standard\src\OpenZiti\API.cs:91  
— End of inner exception stack trace —  
at OpenZiti.ZitiIdentity…ctor (OpenZiti.ZitiIdentity+InitOptions opts) [0x0002e] in D:\a\ziti-sdk-csharp\ziti-sdk-csharp\Ziti.NET.Standard\src\OpenZiti\ZitiIdentity.cs:52  
at Ziti\_ZeroTrust.Weather.Run (System.String identityFile) [0x00064] in C:\Ziti\_ZeroTrust\Ziti\_ZeroTrust\Ziti\_ZeroTrust\Weather.cs:39  
at Ziti\_ZeroTrust.MainPage.Program (System.String args) [0x0004e] in C:\Ziti\_ZeroTrust\Ziti\_ZeroTrust\Ziti\_ZeroTrust\MainPage.xaml.cs:45 }

Kindly help us on resolving this issue.

[Next page](https://openziti.discourse.group/t/how-to-generate-id-jwt-in-ziti-console-for-c-sample-weather-app/913.md?page=2)
