-
Notifications
You must be signed in to change notification settings - Fork 768
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
websockify.py not forwarding data just before connection close #63
Comments
The C version does not have this problem |
Sounds a lot like the issue I raised (#36), but with better documentation. :) Good to know the C version doesn't appear to have the problem, but I haven't had a chance to work on the large message issue there, so a Python fix would be most welcome! |
Oh, I guess I was too eager to report there. I'll just keep this open until kanaka sees it. This one can be closed afterwards, of course, I'm pretty sure that this is a duplicate. |
Thank you for the test case. That made my life much simpler. And sorry for the slow reply. Try 5e16b38. It should at least address your test case. I moved the client socket handling earlier in the loop. The problem with the current situation is that if the target immediately closes after sending the data (which seems to happen sporadically even with the sleep), then the data will never be sent to the client because the next time through the loop it will read from the target, detect that it is closed and never reach the client socket handling. Please also try in the full case where you are seeing the problem. There is still a possible problem where the client socket is busy and so not all the data from the target gets sent, but this is a theoretical possibility and complicates the code so unless people are actually running into I'm hoping this trivial re-ordering will solve what you are actually seeing. |
@kanaka : The problem is fixed. The affected test was emscripten/src/runner.py/test_zz_websockets. |
Great! Thanks for verifying. |
Should at least mostly address this issue: novnc#63 The problem is that the target in the test case often immediately closed the target after sending the data. In this case the last data received from the target is never sent to the client because the client is not in the list of sockets being selected against (because it is only added if their is pending data). By moving the client conditionals first, we give the client socket a chance to be sent data before the target is detected as close and we terminate the loop.
Executing this:
./websockify.py 2300 -- sh -c 'while true; do (echo "test";) | nc -l 2300; done'
and opening wstelnet.html, adjusting the address to localhost:2300 and connecting never gives me any output.This works most of the time, however:
./websockify.py 2300 -- sh -c 'while true; do (echo "test"; sleep 1;) | nc -l 2300; done'
(note the sleep)I am convinced it should work on every connection, cause if I run
while true; do sh -c 'echo "test" | nc -l 2300'; done
andwhile true; do nc localhost 2300; done
I get the expected output (one line per loop iteration).I did not try any of the other implementations, but I'd like to know if they have this problem too.
The text was updated successfully, but these errors were encountered: