Skip to content

Conversation

@gfemec
Copy link

@gfemec gfemec commented Jul 29, 2017

I've been running into a problem with recent versions of ws4py where messages received in quick succession over an SSL connection are not properly parsed.

I believe the problem originated in this commit 75b88bd which can result in the WebSocket.process method being called with more than reading_buffer_size bytes which seems to violate an assumption of the stream/frame parser. In specific, the Stream.receiver coroutine does not pass unused bytes from the previous Frame to the next Frame which causes a problem should a single call to WebSocket.process include data for multiple frames.

The WebSocket.once method has undergone several revisions since this change was first introduced but I believe the original problem remains. My proposed fix restores the old behavior of limiting the size of the byte string passed to WebSocket.process while still consuming all data received by the socket.

I have added a couple unit tests for this behavior. Of particular note is WSWebSocketTest.test_messages_parsing_ssl which fails for me with python 2, 3, and pypy before the proposed change.

@gfemec
Copy link
Author

gfemec commented Jul 29, 2017

closing as a dupe of #220

@gfemec gfemec closed this Jul 29, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant