Im trying to use websocket for a client. The client send some start messages, after that, he can receive messages, whenever he sends something or not. The client is async, and I got some code from doc but I have no idea of what im doing with my life.
async def wsrun(uri):
async with websockets.connect(uri) as websocket:
await websocket.send('hey')
print(await websocket.recv()) # Starts receive things, not only once
asyncio.get_event_loop().run_until_complete(wsrun('wss://localhost:1515'))
The problem is, the websocket recv only shows the first thing that the server send :(
While I can't help you with your life, try this:
async def wsrun(uri):
async with websockets.connect(uri) as websocket:
await websocket.send('hey')
while True:
print(await websocket.recv()) # Starts receive things, not only once
asyncio.get_event_loop().run_until_complete(wsrun('wss://localhost:1515'))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With