I'm trying to make a socket connection between two python files for testing. My server should be uploading some data to clients that are listening. I'm trying to test it by creating some dummy client. After client connects, I'm getting
websocket._exceptions.WebSocketBadStatusException: Handshake status 404 NOT FOUND
Unfortunately I couldn't find any solution online for this error
import time
from threading import Thread
from flask import Flask
from flask_socketio import SocketIO
from flask_sockets import Sockets
from websocket import create_connection
app = Flask(__name__)
socketio = SocketIO(app)
sockets = Sockets(app)
@sockets.route('/socket_test')
def update_time(ws):
while not ws.closed:
ws.send('hello world')
time.sleep(1)
class Client(Thread):
def __init__(self):
super().__init__()
def run(self):
time.sleep(0.5)
ws = create_connection('ws://localhost:5000/socket_test')
while True:
ws.recv()
if __name__ == '__main__':
k = Client()
k.start()
socketio.run(app)
I would like client to receive hello world messages from server