However, I keep getting
Code: Select all
websockets.exceptions.ConnectionClosedError: sent 1011 (unexpected error) keepalive ping timeout; no close frame received
Code: Select all
websockets.exceptions.ConnectionClosedError: sent 1011 (unexpected error) keepalive ping timeout; no close frame received
Code: Select all
import pytest
import websocket
from .credentials import WEBREPL_CREDENTIALS
@pytest.fixture
def client():
ws = websocket.WebSocket()
ws.connect(WEBREPL_CREDENTIALS["url"])
assert "Password: " == ws.recv()
ws.send_binary((WEBREPL_CREDENTIALS["password"]+"/r").encode("utf-8"))
print(ws.recv())
def test_eval(client):
pass
Code: Select all
# websocket_REPL_test.py
# Install websocket-client:
# pip install websocket-client
CRLF = b"\r\n"
command = b'''
1+1
2+2
'''
PASS = b'' + CRLF
IP = '172.16.11.51'
import websocket
import _thread
import time
in_message = ''
def on_message(ws, message):
print(message, end='')
def on_error(ws, error):
print(error)
def on_close(ws, close_status_code, close_msg):
print("### closed ###")
def on_open(ws):
def run(*args):
#ws.settimeout(20)
ws.send(PASS)
for l in command.splitlines():
cmd = l + CRLF
ws.send(cmd)
time.sleep(2)
ws.close()
print("thread terminating...")
_thread.start_new_thread(run, ())
if __name__ == "__main__":
#websocket.enableTrace(True)
ws = websocket.WebSocketApp("ws://" + IP + ":8266",
on_open=on_open,
on_message=on_message,
on_error=on_error,
on_close=on_close)
ws.run_forever()