aio-libs / aio-libs/aiohttp

Websocket timeout needs a print

未關閉
#2,007 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
bug
主要語言
Python
星號
16.5k
分支
2.4k
平均合併
17 小時 22 分鐘
30 天內合併 PR
212

描述

## Long story short

I use a websocket to detect when a page is closed. Every second the page will send a "beat" message. If after 5 seconds I didn't receive anything on the socket, then I consider it dead. The problem is that no timeout happens (or rather it happens only when there is a print in the reading loop).

## Expected behaviour

If no message is received for more than `receive_timeout` time, then a `TimeoutError` shall be raised.

(And the documentation should explain the `WebSocketResponse` constructor arguments, as well).

## Actual behaviour

This happens **only** if there is a `print` statement within the reading loop.

## Steps to reproduce

The original problem comes from the Bernard project. You can see [the reading loop](https://github.com/BernardFW/bernard/blob/d346ccb1511e4251304889a1aeeba21005ca3f5b/src/bernard/platforms/facebook/web.py#L328) as well as the [JS client](https://github.com/BernardFW/bernard/blob/d346ccb1511e4251304889a1aeeba21005ca3f5b/src/bernard/platforms/facebook/web.py#L184).

I could kind of isolate the problem, except that this time doing `print` does not help. You can find the code [in this gist](https://gist.github.com/Xowap/7e9ab562f87ea026b3a227e73fc991d3).

How to proceed:

1. Download the code from the gist and [ngrok](https://ngrok.com/)
2. Install a virtualenv with aiohttp
3. Run in the virtualenv the `test.py` file
4. Start ngrok by doing `ngrok http 8080`
5. Go to the HTTPS link
6. Keep the page open while you close the `ngrok` tunnel
7. Wait for 5 seconds
8. In the console you should see "GOT CLOSED" but instead nothing happens

## Your environment

- Python 3.6.1
- Elementary OS (Ubuntu Xenial)

貢獻指南

開啟貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。