Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle a missing file better in sample client #56

Merged
merged 1 commit into from
Oct 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions sample/ziti-echo-server/ziti-echo-client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@
import openziti
import socket

def netcat_client(ziti_id, service, port):
def netcat_client(ziti_id, service):
try:
zitiContext = openziti.load(ziti_id)
client = openziti.socket(type = socket.SOCK_STREAM) #socket.socket(socket.AF_INET, socket.SOCK_STREAM)
except Exception as e:
print(f'could not find identity file: {e}')
return

try:
client = openziti.socket(type = socket.SOCK_STREAM) #socket.socket(socket.AF_INET, socket.SOCK_STREAM)
port = 65535
client.connect((service, port))
print(f"Connected to {service}:{port}")
print(f"Connected to {service}:there_is_no_port")

while True:
user_input = input("Enter a message: ")
Expand All @@ -35,7 +40,7 @@ def netcat_client(ziti_id, service, port):
print("Server response:", data.decode("utf-8"))

except ConnectionRefusedError:
print(f"Connection to {service}:{port} refused.")
print(f"Connection to {service}:there_is_no_port refused.")
except KeyboardInterrupt:
print("\nConnection closed.")
except Exception as e:
Expand All @@ -44,4 +49,4 @@ def netcat_client(ziti_id, service, port):
client.close()

if __name__ == "__main__":
netcat_client(sys.argv[1], sys.argv[2], int(sys.argv[3]))
netcat_client(sys.argv[1], sys.argv[2])
Loading