Do not hang on non-ready client connection.
Wait 3 seconds for the client to send something. If no data is available within 3 seconds then close the connection. It's probably a non-WebSockets client that is waiting for the server to say something first.
This commit is contained in:
+5
-1
@@ -213,7 +213,11 @@ Connection: Upgrade\r
|
||||
|
||||
stype = ""
|
||||
|
||||
# Peek, but don't read the data
|
||||
ready = select.select([sock], [], [], 3)[0]
|
||||
if not ready:
|
||||
raise self.EClose("ignoring socket not ready")
|
||||
# Peek, but do not read the data so that we have a opportunity
|
||||
# to SSL wrap the socket first
|
||||
handshake = sock.recv(1024, socket.MSG_PEEK)
|
||||
#self.msg("Handshake [%s]" % repr(handshake))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user