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

Hi,

We have downloaded the sample weather app from below path,

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.

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

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

The basic flow is the same as any identity. I’ll assume you have already installed an OpenZiti network using one of the quickstarts. 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

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:

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.

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)

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:

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.

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):

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

Output should look like:

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:

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

Test It Out

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
1 Like

@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?

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!

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!

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 :point_up: 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.

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

That’ll get you to the current doc site which is at OpenZiti .NET SDK (or Namespace OpenZiti)

Hi @RS_MOB and @ac_225,

I’ve published a new (and renamed) version of the dotnet sdk repository. 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.

1 Like

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.

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

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.


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

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?

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.

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

//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?

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
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]
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] 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 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/’, 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.Task1.GetResultCore(Boolean waitCompletionNotification) at System.Threading.Tasks.Task1.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

A post was split to a new topic: Using CloudZiti with the dotnet SDK

I see a bug in the setup script. See ziti-sdk-csharp/weather.ps1 at main · openziti/ziti-sdk-csharp · GitHub

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

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

should be

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

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.

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.


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

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

Kindly help us resolving Access location violation issue.

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… :confused:

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?