Potential Bug: receive_bytes raises 1006 instead of 1011 #3072
Unanswered
Harxyz
asked this question in
Potential Issue
Replies: 1 comment 6 replies
-
|
I think it's not a bug and commonly misunderstood. Close code In client.py you must do Here is my client's result:
# myclient.py
import time
from netizen import HTTPClient
with HTTPClient('localhost', 8000) as client:
response = client.send(
b'GET /ws HTTP/1.1',
b'Upgrade: websocket',
b'Connection: Upgrade',
b'Sec-WebSocket-Key: dGhlIHNhbXBsZSBub25jZQ==',
b'Sec-WebSocket-Version: 13'
)
if response.status == 101:
print('Received (data):', client.recv(4096)) # b'\x81\r{"counter":1}'
print('Received (ping):', client.recv(4096)) # server send ping, consume it
# time.sleep(15)
close_frame = client.recv(4096) # real close code
print('Received (close):', close_frame)
print('code:', int.from_bytes(close_frame[2:4], 'big')) |
Beta Was this translation helpful? Give feedback.
6 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
#2383 following up on this discussion I don't think this has been solved yet, hence raising it again. Any plans to fix the status code here? On ping timeout a 1006 is being raised instead of 1011 when calling receive_bytes. I have added some code below to reproduce it. Would appreciate if this could be fixed? thanks
server.py
client.py
Trace
Beta Was this translation helpful? Give feedback.
All reactions