-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
websocket connection is closing. #1768
Comments
Without looking at the example in detail I suspect you're getting What's weird and more problematic for me is that (perhaps because it's If you put try:
...
except Exception as e:
print(e.__class__.__name__, e)
raise Around your code you'll see the error. |
maybe we beed to add signal for disconnection or something |
That would be useful, this confused me for a while and has required a fix in asyncpg. |
I re-read issue, i need more information. what do you get? warning? error? |
I can not repreduce this bug now, I've made some change, add |
@fafhrd91 Now I just test weather the connection is closed silently, I raised my own Exception in this case. The connection is always exit with error code 258, I've found nothing about it. |
I got this issue as same. Basically when the remote connection is closing, the |
In my case, most causes is closing action (cancel request) by client, raised
|
Actually I’ve already caught the CancelledError outside the for loop.
… On Mar 17, 2019, at 9:11 PM, Michael ***@***.***> wrote:
In my case, most causes is closing action (cancel request) by client, raised asyncio.CancelledError Exception. You can catch exception like this:
try:
async for msgobj in ws:
....
except asyncio.CancelledError:
printf(f"the websocket({ws}) cancelled")
finally:
await conn.close('finally')
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#1768 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/AA88ztiGsfmLAms2pD5okSUdu_K96_DYks5vXxIHgaJpZM4MspxH>.
|
I have the code like this:
And in log it always complains "Loop exit abnormally" |
Maybe you can try to check more type of wsobj, such as:
|
Interestingly, I have something like
But I never see anything related in the log which suggests the for loop exits silently. |
By looking into the source code, I found this in aiohttp
https://github.com/aio-libs/aiohttp/blob/master/aiohttp/client_ws.py#L295 I think this perfectly solved this problem: aiohttp WON'T inform you about the websocket closing if you are using |
The problem for me (and probably in this case) is that you have another thread (bg_sending) that is trying to send over the websocket after the bg_receive function. The It does inform you of the websocket connection closing by virtue of exiting the loop. |
I know this is years late and I doubt it's hopeful to the OP but it might be useful to the debugging efforts of others as the other comments on this thread have been for me! :) Your The exception might not be None, however just a few lines before you call |
I think the exception to catch is |
websocket connection is closing. but no Exception raise
I can't know whether a connection is available?
websocket connection is closing. socket.send() raised exception.
Expected behaviour
If there is a error, an Exception should be raise.
Actual behaviour
It is a warning? not Exception raised
Steps to reproduce
wait a long time, and websocket send_json failed with this warning
Your environment
Ubuntu 16.04
Anaconda 4.3.1
Python 3.6.1
aiohttp 2.0.4
The text was updated successfully, but these errors were encountered: