# Delay on first request

**URL:** <https://openziti.discourse.group/t/delay-on-first-request/5121>\
**Category:** Ziti Overlay\
**Created:** [September 18, 2025, 2:18pm UTC](https://openziti.discourse.group/t/delay-on-first-request/5121 "2025-09-18T14:18:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathis](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@Mathis](https://openziti.discourse.group/u/Mathis)\
**Post date:** [September 18, 2025, 2:18pm UTC](https://openziti.discourse.group/t/delay-on-first-request/5121/1 "2025-09-18T14:18:43Z")

</div>

Hello everyone, I have a simple setup with a host and client, where the host has a GET route which just returns some text.  
The client uses the python SDK with monkeypatching, here’s the code :

“import os  
import openziti  
import requests

ztx = openziti.load("ziti/identity.json")  
if ztx is None:  
raise RuntimeError("Identity load failed")

openziti.monkeypatch()

resp = requests.get("[http://winpreprod.zpix:2612/pix/out/v1.0/GetToken](http://winpreprod.zpix:2612/pix/out/v1.0/GetToken)")  
print(resp.status\_code)  
print(resp.text)  
”

The code works as expected and returns the intended response, but there is roughly a 10-second delay before the first response. When making multiple requests in a row (with a for loop before `requests.get`), the same ~10-second delay occurs only for the first request, while all subsequent responses arrive instantly. It seems to me that the delay is caused by the initial setup of the Ziti tunnel, but I don’t have any idea on why it’s the case.

I also can’t manage to have the logs printed with the Python SDK, even when setting ZITI\_LOG\_LEVEL=debug, so I don’t have more infos.

Any help would be greatly appreciated

---

<div class="post-metadata">

**Author:** ![qrkourier](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/qrkourier/32/52_2.png) [@qrkourier](https://openziti.discourse.group/u/qrkourier)\
**Post date:** [September 18, 2025, 3:31pm UTC](https://openziti.discourse.group/t/delay-on-first-request/5121/2 "2025-09-18T15:31:53Z")

</div>

Do you get a better result with the context manager approach shown in this `requests` example?

> **[ziti-sdk-py/sample/ziti-requests at main · openziti/ziti-sdk-py](https://github.com/openziti/ziti-sdk-py/tree/main/sample/ziti-requests)**
>
> Ziti SDK for Python. Contribute to openziti/ziti-sdk-py development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![ekoby](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/ekoby/32/14_2.png) [@ekoby](https://openziti.discourse.group/u/ekoby)\
**Post date:** [September 18, 2025, 3:57pm UTC](https://openziti.discourse.group/t/delay-on-first-request/5121/3 "2025-09-18T15:57:54Z")

</div>

correct environment variable is ZITI\_LOG, and it is numeric -- 1 -\> ERROR, 2 -\> WARN, etc

---

<div class="post-metadata">

**Author:** ![Mathis](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@Mathis](https://openziti.discourse.group/u/Mathis)\
**Post date:** [September 19, 2025, 7:47am UTC](https://openziti.discourse.group/t/delay-on-first-request/5121/4 "2025-09-19T07:47:57Z")

</div>

The same delay applies as well with the example code.  
With ZITI\_LOG=4, I can see what’s causing the delay. There’s 2 instances :  
”(91054)[0.001] DEBUG ziti-sdk:ziti\_ctrl.c:1106 ctrl\_paging\_req() ctrl[[https://zpix.vigitronic.eu:8440/edge/client/v1\](https://zpix.vigitronic.eu:8440/edge/client/v1%5C)] starting paging request GET[/external-jwt-signers]  
(91054)[5.064] DEBUG ziti-sdk:ziti\_ctrl.c:502 ctrl\_body\_cb() ctrl[[https://zpix.vigitronic.eu:8440/edge/client/v1\](https://zpix.vigitronic.eu:8440/edge/client/v1%5C)] completed GET[/version] in 5.057 s”

“(91054)[5.302] DEBUG ziti-sdk:connect.c:527 process\_connect() conn[0.0/6MuOgQPn/Connecting](2612) requesting 'Dial' session for service[2612]  
(91054)[10.201] DEBUG ziti-sdk:channel.c:966 on\_tls\_connect() ch[0] connected alpn[ziti-edge]”

From what I see the delay seems to come from the controller (or the network but I doubt it), but I don’t really know what could cause that

---

<div class="post-metadata">

**Author:** ![ekoby](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/ekoby/32/14_2.png) [@ekoby](https://openziti.discourse.group/u/ekoby)\
**Post date:** [September 19, 2025, 2:04pm UTC](https://openziti.discourse.group/t/delay-on-first-request/5121/5 "2025-09-19T14:04:32Z")

</div>

> [@Mathis](#):
>
> ```auto
> (91054)[5.064] DEBUG ziti-sdk:ziti_ctrl.c:502 ctrl_body_cb() ctrl[[https://zpix.vigitronic.eu:8440/edge/client/v1\](https://zpix.vigitronic.eu:8440/edge/client/v1%5C)] completed GET[/version] in 5.057 s
> 
> ```

this is what (probably) causing the delay. it looks like a slow DNS resolution

What OS are you running on?

can you try hitting controller URL with cURL?  
Can you run wireshark or tcpdump to see packet flow for that connection? make sure to capture DNS requests as well

---

<div class="post-metadata">

**Author:** ![Mathis](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@Mathis](https://openziti.discourse.group/u/Mathis)\
**Post date:** [September 19, 2025, 2:47pm UTC](https://openziti.discourse.group/t/delay-on-first-request/5121/6 "2025-09-19T14:47:44Z")

</div>

Hey, thanks for your answer.  
It was actually due to a DNS problem as you figured.  
After a bit of digging, I found that the first DNS address in /etc/resolv.conf was faulty. I’m pretty sure it’s an old, deleted DNS server used when I had the tunneler installed instead of the SDK. It works nicely after removing it

Sorry the issue wasn’t really related to Ziti but thanks for your help and solution!

---

<div class="post-metadata">

**Author:** ![ekoby](https://yyz2.discourse-cdn.com/free1/user_avatar/openziti.discourse.group/ekoby/32/14_2.png) [@ekoby](https://openziti.discourse.group/u/ekoby)\
**Post date:** [September 19, 2025, 2:49pm UTC](https://openziti.discourse.group/t/delay-on-first-request/5121/7 "2025-09-19T14:49:17Z")

</div>

> [@Mathis](#):
>
> Sorry the issue wasn’t really related to Ziti but thanks for your help and solution!

no worries, and thanks for the update
