-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Websocket client hanging/blocking? #3291
Comments
it looks like client_ws.py#L204 is not returning... any ideas? The server is a SkyQ set-top box, so might not be entirely RFC-compliance implementation of WS. For example, it doesn't honour ping/poings... And there is that weird |
Websocket is a binary protocol |
those bytes look like this end-to-end... I am not an expert on th RFC, but what is this saying in terms of type and length? Do you think the problem is with that? Ie, it not agreeing to the actual payload length, and the thing waiting for an extra frame, for example? |
Interestingly, this web socket cli client, written in go, handles the output fine, including that binary stuff at the top:
|
The protocol says: the first |
I assume you are referring to the 2d, 3rd and 4th bit in the base framing protocol. In which case yes, maybe I did get it wrong. It could be a unicode/ASCII issue. I'll take another look. |
I've tried a few other online converters... I'm getting this now: If according the RFC 6455
Then it looks like The number of the characters in the JSON doc is The RFC says this about payload length:
So, given all that, where do we go next? If the server is brain-dead and not RFC compliant, then I need to work around it as other client's clearly can do... Can you offer any suggestions? |
Still looks suspicious. Unless you don't know what the server sends there is no way to "fix" a client. |
@asvetlov I tried the
|
Hi @asvetlov
I think you meant "unless, you do know what a server sends, you cannot fix a client." In which case, I completely disagree with this point. You are familiar with the Robustness Principle? "Be conservative in what you send, and liberal in what you receive." Regardless of MUSTs and SHOULDs and MUST NOTs, in the RFC, I think you are interpreting and expecting entities to comply with the RFC completely... Clearly they do not, and many many internet servers and clients out there, of various types, have horrendous bastardised half-implementations of protocols. A good library/protocol implementation must be forgiving of these to the extent that it can. See RFC1122. It is completely possible to write a protocol client to be forgiving of (some) protocol violations without having access to the other participant in the communication. I feel this is not the case here, you seem to be taking the hard-line view that if a host is not 100% compliant then too bad for it, we will not talk to it. This is too bad. It's like saying: 'I only speak the Queen's English, and if you come talking to me in some weird dialect of English, I won't talk to you.' Clearly this is not a good approach if the whole point of the library is to facilitate communication. My suggestion, therefore, is to consider where you can relax stringent requirements of the protocol (maybe via method kwargs, that turn on the "relaxed" handling), and see if you can make things talk even when the other side is not behaving properly. Aside from this critique, I'd like to thank you and the contributors from |
@asvetlov Just an update on this... I figured out that my (non-compliant) server requires an uppercase |
Current releases send the upgrade header in that format, so unless there's a method to reproduce the original issue, there's not much we can do here. |
Long story short
ws.receive()
appears to be hanging despite data flowing from websocket.Expected behaviour
ws.receive
should output and report something.Actual behaviour
it just hangs/blocks on the websocket.
Steps to reproduce
The code below is the calling code.
Resulting log:
However, the socket is open and serving data as can be seen by netcat.
Your environment
update...
Python version is 3.7.0
The text was updated successfully, but these errors were encountered: