-
Hello, I'm trying to make a Kathará POC with a simple Rest API lab. To do this, I'm using custom images of Kathará in which I've installed python 3.11. # server.py
from fastapi import FastAPI
from random import randint
app = FastAPI()
@app.get("/")
async def root(
start: int = 0,
end: int = 100
):
rand_int = randint(start, end)
return {"data": rand_int} # client.py
import requests
response = requests.get("http://10.0.0.1:8000/")
print(response.json()) The Kathará files are such as : # lab.conf
client[0]=A
client[image]="usecase3-client"
server[0]=A
server[image]="usecase3-server"
# server.startup
ifconfig eth0 10.0.0.1 netmask 255.255.255.0 up
# client.startup
ifconfig eth0 10.0.0.2 netmask 255.255.255.0 up
python-work ./client.py
# lab.dep
client: server Here's my problem, when I launch the lab, with the line HTTPConnectionPool(host='10.0.0.1', port=8000): Max retries exceed with url: / (Caused by NewConnectionError('<urllib3.connection.HTTPConnection object at 0x7ff791ea2510>: Failed to establish a new connection: [Errno 111] Connection refused')) But when I run the same command in the terminal right afterwards, it works and I get this:
I don't really understand how to do it. Do you have a solution so that I can make it work? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hi @MrStaf, I need to play with the lab to understand what is happening. Can you please attach your lab and the Dockerfile to build your custom image? Anyway, today we released the new docker images based on Debian 12. They come with Python3.11 installed 😇 Thanks, |
Beta Was this translation helpful? Give feedback.
Hi @MrStaf,
I tried the lab 😃
It seems that your problem is caused by the client that queries the server before this is ready.
If you add the line
CMD ["python-work", "client.py"]
in the usecase3-client image the terminal crashes becauseclient.py
raises an exception since the server is not ready.There are many way to circumvent this issue, a simple one could be to force the client to make the request until the server is ready.
I…