Skip to content
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

[WebSocketFrame] Exception when building frames with very large payloads #912

Open
abhinavsingh opened this issue Dec 27, 2021 · 0 comments · May be fixed by #914
Open

[WebSocketFrame] Exception when building frames with very large payloads #912

abhinavsingh opened this issue Dec 27, 2021 · 0 comments · May be fixed by #914
Labels
Bug Bug report in proxy server Good First Issue Issues for new contributors to pick-up

Comments

@abhinavsingh
Copy link
Owner

Describe the bug
When building a WebSocket frame with very large payload (8 bytes represented as 64-bit unsigned integer as payload length), following exception is seen:

2021-12-27 21:11:52,797 - pid:75191 [E] base_events.default_exception_handler:1729 - Task exception was never retrieved
future: <Task finished name='Task-1' coro=<Threadless._run_forever() done, defined at /Users/abhinavsingh/Dev/proxy.py/proxy/core/acceptor/threadless.py:346> exception=error('pack expected 3 items for packing (got 2)')>
Traceback (most recent call last):
  File "/Users/abhinavsingh/Dev/proxy.py/proxy/core/acceptor/threadless.py", line 350, in _run_forever
    if await self._run_once():
  File "/Users/abhinavsingh/Dev/proxy.py/proxy/core/acceptor/threadless.py", line 334, in _run_once
    teardown = task.result()
  File "/Users/abhinavsingh/Dev/proxy.py/proxy/http/handler.py", line 192, in handle_events
    teardown = await plugin.read_from_descriptors(readables)
  File "/Users/abhinavsingh/Dev/proxy.py/proxy/http/proxy/server.py", line 299, in read_from_descriptors
    raw = plugin.handle_upstream_chunk(raw)
  File "/Users/abhinavsingh/Dev/proxy.py/proxy/plugin/modify_websocket_response.py", line 32, in handle_upstream_chunk
    self.client.queue(memoryview(self.response.build()))
  File "/Users/abhinavsingh/Dev/proxy.py/proxy/http/websocket/frame.py", line 161, in build
    struct.pack(
struct.error: pack expected 3 items for packing (got 2)

To Reproduce
Steps to reproduce the behavior:

  1. Start proxy.py
  2. ./helper/chrome_with_proxy.sh
  3. See exception in console

Expected behavior
There seems to be a typo error here:

elif self.payload_length < 1 << 64:
            raw.write(
                struct.pack(
                    '!BHQ',
                    (1 << 7 if self.masked else 0) | 127,
                    self.payload_length,
                ),
            )

We simply want !BQ and not !BHQ. But need to double check with spec and write tests for it. Opening this issue to track the same.

@abhinavsingh abhinavsingh added Bug Bug report in proxy server Good First Issue Issues for new contributors to pick-up labels Dec 27, 2021
@abhinavsingh abhinavsingh linked a pull request Dec 27, 2021 that will close this issue
@abhinavsingh abhinavsingh pinned this issue Jan 14, 2022
@abhinavsingh abhinavsingh unpinned this issue Jan 17, 2022
@abhinavsingh abhinavsingh pinned this issue Jan 20, 2022
@abhinavsingh abhinavsingh unpinned this issue Jan 22, 2022
@abhinavsingh abhinavsingh pinned this issue Jan 25, 2022
@abhinavsingh abhinavsingh unpinned this issue Jun 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Bug report in proxy server Good First Issue Issues for new contributors to pick-up
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant