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

Added ServiceRestart and TryAgainLater websocket close codes #828

Merged
merged 2 commits into from
Mar 15, 2016

Conversation

MarSoft
Copy link
Contributor

@MarSoft MarSoft commented Mar 13, 2016

What these changes does?

Allows using IANA standard websocket close codes 1012 Service Restart and 1013 Try Again Later

How to test your changes?

async def myws(request):
    ws = WebSocketResponse()
    await ws.prepare(request)
    # ...
    await ws.close(code=1012, message='Service Restart')

Expected behaviour: websocket closed with 1012 code
Actual behaviour without this PR:

[2016-03-14 00:05:08 +0300] [26962] [ERROR] Error handling request
Traceback (most recent call last):
  File "/usr/lib/python3.5/site-packages/aiohttp/web_ws.py", line 230, in receive
    msg = yield from self._reader.read()
  File "/usr/lib/python3.5/site-packages/aiohttp/streams.py", line 591, in read
    result = yield from super().read()
  File "/usr/lib/python3.5/site-packages/aiohttp/streams.py", line 446, in read
    yield from self._waiter
  File "/usr/lib/python3.5/asyncio/futures.py", line 358, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.5/asyncio/tasks.py", line 290, in _wakeup
    future.result()
  File "/usr/lib/python3.5/asyncio/futures.py", line 274, in result
    raise self._exception
  File "/usr/lib/python3.5/site-packages/aiohttp/parsers.py", line 139, in feed_data
    self._parser.send(data)
  File "/usr/lib/python3.5/site-packages/aiohttp/websocket.py", line 86, in WebSocketParser
    'Invalid close code: {}'.format(close_code))
aiohttp.websocket.WebSocketError: Invalid close code: 1012

Related issue number

None

Checklist

  • Code is written and well
  • Tests for the changes are provided
  • Documentation reflects the changes

These codes are listed in IANA registry: https://www.iana.org/assignments/websocket/websocket.xml#table-close-code-number
But without this change aiohttp doesn't allow to use them.

These codes are listed in IANA registry: https://www.iana.org/assignments/websocket/websocket.xml#table-close-code-number
But without this change `aiohttp` doesn't allow to use them.
@popravich
Copy link
Member

Please add tests

@MarSoft
Copy link
Contributor Author

MarSoft commented Mar 14, 2016

Not sure where should I put that testing. Placed it in test_close which looks most logical for me.

asvetlov added a commit that referenced this pull request Mar 15, 2016
Added ServiceRestart and TryAgainLater websocket close codes
@asvetlov asvetlov merged commit 9236e65 into aio-libs:master Mar 15, 2016
@asvetlov
Copy link
Member

thanks

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants