aio-libs / aio-libs/aiohttp

Websocket timeout needs a print

Abierto
#2,007 1 comentario 0 reacciones 0 asignados Ver en GitHub
bug
Lenguaje dominante
Python
Estrellas
16.5k
Forks
2.4k
Merge medio
17 h 22 min
PR fusionados (30 d)
212

Descripción

## 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)

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.