Creating a share in Zrok python SDK

I'm trying to create a share and maintain it open using the python SDK for Zrok, I have a c# http server running on port 8000

#!python3
import sys
import zrok
from zrok.model import ShareRequest
import atexit


zrok_opts = {}

root = zrok.environment.root.Load()
try:
        shr = zrok.share.CreateShare(root=root, request=ShareRequest(
            BackendMode=zrok.model.TCP_TUNNEL_BACKEND_MODE,
            ShareMode=zrok.model.PUBLIC_SHARE_MODE,
            Frontends=['public'],
            Target="http://localhost:8000"
        ))
        shrToken = shr.Token
        print("Access server at the following endpoints: ", "\n".join(shr.FrontendEndpoints))

except Exception as e:
        print("unable to create share", e)
        sys.exit(1)


input("Press enter to continue...")

while this can create a share :

Access server at the following endpoints:  http://kh8l5dcjkdij.zrok.xxxxxx.com
Press enter to continue...

the share doesn't seem to be accessible ( says not found )

am I missing something in the SDK code?

It looks like you're creating the share... but there's no listener?

If you don't actually start a listener, there is nothing to connect to and you'll end up getting a 404.

If you look at the full HTTP example, you'll see there is an HTTP server instantiated... that includes a listener:

If you look at the copyto portion of the pastebin example:

...you'll see that it's directly creating a listener:

        with zrok.listener.Listener(shr.Token, root) as server:
            while not exit_signal.is_set():
                conn, peer = server.accept()
                with conn:
                    conn.sendall(data.encode('utf-8'))

I saw the http_server example, can we create a share and listener without using waitress/flask ? because my website is a c# app listening on port 8000

Yes... there's an example at the bottom of my last post showing a listener in Python without using waitress/flask.

If you're looking to just proxy a C# application, you're probably better off using the zrok share CLI... the Python SDK does not include a reverse proxy implementation. If you're using the SDK, it's expected that you're embedding it in an application that wants to communicate on the network directly... not proxy to another application.

If you want a proxy in Python, you'll need to build that yourself.