close_connection doesn't close() because sock.shutdown crashes first.

Open
#259 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
networking

Research direction

Start in ws4py/websocket.py at close_connection and inspect how shutdown and close are handled for SSL sockets. Reproduce the CherryPy/SSL failure if possible, then verify that socket.close() is still reached when shutdown raises the reported OSError.

Written by the indexing model from the issue text.

Description

When using cherrypy and ssl, for reasons I don't understand, the sock.shutdown call throws this error occasionally(When the source is modified to print tracebacks instead of silently pass).

Traceback (most recent call last):
  File "/home/daniel/Projects/KaithemAutomation/kaithem/src/thirdparty/ws4py/websocket.py", line 210, in close_connection
    self.sock.shutdown(socket.SHUT_RDWR)
  File "/usr/lib/python3.6/ssl.py", line 1050, in shutdown
    socket.shutdown(self, how)
OSError: [Errno 107] Transport endpoint is not connected

Seeing as how this is in the same try/except block as socket.close(), I presume that socket.close() is not always being called. Because of circular refs it might or might not get GCed right away, and if it does not, it may have something to do with some of the remaining bad behavior.

I will be testing with giving shutdown it's own try/except block and seeing how that goes.

Dominant language
Python
Stars
1.1k
Forks
285
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Lawouach/WebSocket-for-Python

All issues in Lawouach/WebSocket-for-Python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.