Client/Server Programs in Python

Just curious as to whether we can run client/server type programs in the Python IDE, for example, by importing Redis() or zmq, or some package like that. I’m not thinking of running a true internet server from my Replit account (!); I just want to test some client/server programs by running them in the same directory in the Replit shell. Is that possible/allowed? Here are the programs:

SERVER: https://replit.com/@jamespbrennan/Redis#main.py
CLIENT: https://replit.com/@jamespbrennan/Redis#redis_sub.py

2 Likes

Give it a shot, it won’t hurt, and if it works, great. If it doesn’t, you’ll probably have to consult a staff member or someone who knows more than me xD.

try it out and see if it works idk

There used to be a thing where any sockets started would be instantly forced-linked to the web and that made things like your describing impossible, it might be fixed now though.

It isn’t working. That’s why I posted. Whenever I try to run either the client or server program, I get this very long error message:

Traceback (most recent call last):
File “/home/runner/Redis/venv/lib/python3.10/site-packages/redis/connection.py”, line 624, in connect
sock = self.retry.call_with_retry(
File “/home/runner/Redis/venv/lib/python3.10/site-packages/redis/retry.py”, line 46, in call_with_retry
return do()
File “/home/runner/Redis/venv/lib/python3.10/site-packages/redis/connection.py”, line 625, in
lambda: self._connect(), lambda error: self.disconnect(error)
File “/home/runner/Redis/venv/lib/python3.10/site-packages/redis/connection.py”, line 690, in _connect
raise err
File “/home/runner/Redis/venv/lib/python3.10/site-packages/redis/connection.py”, line 678, in _connect
sock.connect(socket_address)
OSError: [Errno 99] Cannot assign requested address

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “/home/runner/Redis/redis_sub.py”, line 6, in
sub.subscribe(topics)
File “/home/runner/Redis/venv/lib/python3.10/site-packages/redis/client.py”, line 1623, in subscribe
ret_val = self.execute_command(“SUBSCRIBE”, *new_channels.keys())
File “/home/runner/Redis/venv/lib/python3.10/site-packages/redis/client.py”, line 1458, in execute_command
self.connection = self.connection_pool.get_connection(
File “/home/runner/Redis/venv/lib/python3.10/site-packages/redis/connection.py”, line 1427, in get_connection
connection.connect()
File “/home/runner/Redis/venv/lib/python3.10/site-packages/redis/connection.py”, line 630, in connect
raise ConnectionError(self._error_message(e))
redis.exceptions.ConnectionError: Error 99 connecting to localhost:6379. Cannot assign requested address.

And yes, I did import the redis package, so that’s not it.

I don’t think localhost works on replit, host it on 0.0.0.0

If you want to, you can with Python Flask. Some people do. There are Flask templates on Replit. I’ve played around with Flask but I don’t think I currently have anything I’m actually using running on Flask.

I’ll give that a try. Thanks!

Interesting suggestion. I didn’t know anything about Python Flask. I’ll give it a look. Thanks!

Localhost does work I use it

On replit? Can you make an example?