Skip to content

Troubleshooting Kathara POC with Python 3.11: Client-Server Communication Issue #242

Closed Answered by tcaiazzi
MrStaf asked this question in Q&A
Discussion options

You must be logged in to vote

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 because client.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.

# client.py
import time

import requests


def get_response():
    try:
        return requests.get("http://10.0.0.1:8000/")
    except Exception:
        time.sleep(0.1)
        return get_response()


if __name__ == '__main__':
    print(get_response().json())

I…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@MrStaf
Comment options

@tcaiazzi
Comment options

Answer selected by MrStaf
@MrStaf
Comment options

@tcaiazzi
Comment options

@MrStaf
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants