diff options
| author | engn33r <engn33r@users.noreply.github.com> | 2021-06-02 09:34:51 -0400 |
|---|---|---|
| committer | engn33r <engn33r@users.noreply.github.com> | 2021-06-02 09:34:51 -0400 |
| commit | fcb022c1e38bfd1c74f618ac9800ba9f263cbcfc (patch) | |
| tree | cdc5c86094c56698d9a499ba5d61b408e1dfc493 /docs/source | |
| parent | 60e4711b1a7b1589411e398cf62dda84983abd24 (diff) | |
| download | websocket-client-fcb022c1e38bfd1c74f618ac9800ba9f263cbcfc.tar.gz | |
Add callback on_error() tip to FAQ docs
Diffstat (limited to 'docs/source')
| -rw-r--r-- | docs/source/faq.rst | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/source/faq.rst b/docs/source/faq.rst index ea14bb5..c4642a9 100644 --- a/docs/source/faq.rst +++ b/docs/source/faq.rst @@ -21,6 +21,32 @@ doubles the speed of UTF8 validation while both numpy and wsaccel offer a minor performance boost when masking the payload data as part of the ``send`` process. +How to troubleshoot an unclear callback error? +=================================================== + +To get more information about a callback error, you can +specify a custom ``on_error()`` function that raises errors +to provide more information. Sample code of such a solution +is shown below, although the example URL provided will probably +not trigger an error under normal circumstances. +`Issue #377 <https://github.com/websocket-client/websocket-client/issues/60>`_ +discussed this topic previously. + +:: + + import websocket + + def on_message(ws, message): + print(message) + + def on_error(wsapp, err): + print("Got a an error: ", err) + + wsapp = websocket.WebSocketApp("ws://echo.websocket.org/", + on_message = on_message, + on_error=on_error) + wsapp.run_forever() + How to solve the "connection is already closed" error? =========================================================== |
