Browse Source

wsclient reconnects automatically

closes #6
boyska 1 year ago
parent
commit
c2abb5ba31
2 changed files with 5 additions and 1 deletions
  1. 1 0
      README.md
  2. 4 1
      utils/wsclient.py

+ 1 - 0
README.md

@@ -30,6 +30,7 @@ a questo punto lancia `docker-compose up`
 ### GUI
 
 ```
+apt install python3-websocket
 ./utils/wsclient.py -k 'wss://localhost:8000/v1/ws/counter/0' | stdbuf -o0 jq .value |  ./schermetto/num_display.py  --no-fu --inve 4
 ```
 

+ 4 - 1
utils/wsclient.py

@@ -1,6 +1,7 @@
 #!/usr/bin/python3 -u
 import argparse
 import ssl
+import time
 
 import websocket
 
@@ -34,7 +35,9 @@ def main():
     run_opts = {}
     if not args.ssl_verify:
         run_opts = {"sslopt": {"cert_reqs": ssl.CERT_NONE}}
-    wsapp.run_forever(**run_opts)
+    while True:
+        wsapp.run_forever(**run_opts)
+        time.sleep(1)
 
 
 if __name__ == "__main__":