Skip to content
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

Error on connection.close() #28

Open
kenfehling opened this issue Jul 1, 2017 · 5 comments
Open

Error on connection.close() #28

kenfehling opened this issue Jul 1, 2017 · 5 comments

Comments

@kenfehling
Copy link

Hi. First off thanks for bringing SignalR to Python!

I'm getting an error when I try to call connection.close() and it's really perplexing me, especially since none of the lines in the stack trace are my code.

Traceback (most recent call last):
  File "/Users/ken/anaconda/lib/python3.6/site-packages/gevent/greenlet.py", line 536, in run
    result = self._run(*self.args, **self.kwargs)
  File "/Users/ken/anaconda/lib/python3.6/site-packages/signalr/_connection.py", line 53, in wrapped_listener
    listener()
  File "/Users/ken/anaconda/lib/python3.6/site-packages/signalr/transports/_ws_transport.py", line 42, in _receive
    for notification in self.ws:
  File "/Users/ken/anaconda/lib/python3.6/site-packages/websocket/_core.py", line 105, in __iter__
    yield self.recv()
  File "/Users/ken/anaconda/lib/python3.6/site-packages/websocket/_core.py", line 293, in recv
    opcode, data = self.recv_data()
  File "/Users/ken/anaconda/lib/python3.6/site-packages/websocket/_core.py", line 310, in recv_data
    opcode, frame = self.recv_data_frame(control_frame)
  File "/Users/ken/anaconda/lib/python3.6/site-packages/websocket/_core.py", line 323, in recv_data_frame
    frame = self.recv_frame()
  File "/Users/ken/anaconda/lib/python3.6/site-packages/websocket/_core.py", line 357, in recv_frame
    return self.frame_buffer.recv_frame()
  File "/Users/ken/anaconda/lib/python3.6/site-packages/websocket/_abnf.py", line 336, in recv_frame
    self.recv_header()
  File "/Users/ken/anaconda/lib/python3.6/site-packages/websocket/_abnf.py", line 286, in recv_header
    header = self.recv_strict(2)
  File "/Users/ken/anaconda/lib/python3.6/site-packages/websocket/_abnf.py", line 371, in recv_strict
    bytes_ = self.recv(min(16384, shortage))
  File "/Users/ken/anaconda/lib/python3.6/site-packages/websocket/_core.py", line 427, in _recv
    return recv(self.sock, bufsize)
  File "/Users/ken/anaconda/lib/python3.6/site-packages/websocket/_socket.py", line 80, in recv
    bytes_ = sock.recv(bufsize)
  File "/Users/ken/anaconda/lib/python3.6/site-packages/gevent/_ssl3.py", line 460, in recv
    return self.read(buflen)
  File "/Users/ken/anaconda/lib/python3.6/site-packages/gevent/_ssl3.py", line 282, in read
    raise ValueError("Read on closed or unwrapped SSL socket.")
ValueError: Read on closed or unwrapped SSL socket.
Sat Jul  1 17:13:01 2017 <Greenlet at 0x1223a5768: wrapped_listener> failed with ValueError
@PaulPatena
Copy link

PaulPatena commented Oct 29, 2017

I'm having the exact same issue. Im using python 2.7.12 and signalr-client 0.0.7. When I close the connection, I traced the call stack, it would hang when executing this line.
image

@i3wangyi
Copy link

Same to me! Any ideas on how to catch the exception?

@PlamenHristov
Copy link

PlamenHristov commented May 31, 2018

The code needs to be changed to:

def close(self):
       gevent.kill(self.__greenlet)
       while not self.__greenlet.dead:
               gevent.sleep()
       self.__transport.close()

You need to wait for gevent to stop the listener, otherwise the close() and listener() try to aquire the same lock and deadlock themselves.

@ngunhaSO
Copy link

ngunhaSO commented Dec 6, 2018

Any update for this issue?

@k12007
Copy link

k12007 commented May 12, 2019

@PlamenHristov thanks for providing the solution!(finally no longer see that annoying exception)
@ngunhaSO I believe signalr-client is no longer active, so you going have to get your hands dirty and change the code yourself (or find a fork that is active)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants