I am use python asyncio to create a websocket client, however, when I try the following code, it hangs up
message = b''
while True:
print(11111)
chunk = await reader.read(1024)
print(len(chunk))
self.message += chunk
print(self.connection['reader'].at_eof())
if not chunk:
break
print('eeeeeeee')
However, it hangs up and output:
11111
35
False
How can I check if the buffer is end?
WebSockets are much more complex protocol than plain TCP socket. You need to use a library for working with it: aiohttp, websockets or autobahn.
P.S.
I'm aiohttp author, the library supports plain HTTP protocol as well as WebSockets.