Called when a client closes a websocket connection
495183
def onClose(self, was_clean, code, reason):
        
        logger.debug("Connection closed ({peer})".format(peer=self.peer))

        # Publish ON_CLOSE message
        self.factory.mease.publisher.publish(
            message_type=ON_CLOSE, client_id=self._client_id, client_storage=self.storage)

        self.factory.remove_client(self)
1223400
protected function disconnect()
    {
        // Initiate connection close. The WebSockets RFC recomends against
        // clients initiating the close handshake but we want to ensure the
        // connection is closed as soon as possible.
        $this->connection->startClose(
            Net_Notifier_WebSocket_Connection::CLOSE_GOING_AWAY,
            'Client sent message.'
        );

        // read server close frame
        $state = $this->connection->getState();

        $sec  = intval($this->timeout / 1000);
        $usec = ($this->timeout % 1000) * 1000;

        while ($state < Net_Notifier_WebSocket_Connection::STATE_CLOSED) {
            $read = array($this->socket->getRawSocket());

            $result = stream_select(
                $read,
                $write = null,
                $except = null,
                $sec,
                $usec
            );

            if ($result === 1) {
                $this->connection->read(self::READ_BUFFER_LENGTH);
            } else {
                // read timed out, just close the connection
                $this->connection->close();
            }

            $state = $this->connection->getState();
        }

        $this->connection = null;
    }
120863
public void close() throws IOException {
        if (isClosed()) {
            return;
        }

        if (!_webSocket.isDisconnected()) {
            String s = "Can't close the MessageReader if the WebSocket is " +
                       "still connected";
            throw new WebSocketException(s);
        }
        
        _sharedQueue.done();
        _closed = true;
    }
1028613
private void checkCloseConnection(ChannelFuture future) {
        // If this connection is closing and the graceful shutdown has completed, close the connection
        // once this operation completes.
        if (closeListener != null && isGracefulShutdownComplete()) {
            ChannelFutureListener closeListener = this.closeListener;
            // This method could be called multiple times
            // and we don't want to notify the closeListener multiple times.
            this.closeListener = null;
            try {
                closeListener.operationComplete(future);
            } catch (Exception e) {
                throw new IllegalStateException("Close listener threw an unexpected exception", e);
            }
        }
    }
1259925
synchronized void closeSocket() {

        @Nullable SocketChannel clientChannel = this.clientChannel;

        if (clientChannel != null) {

            try {
                clientChannel.socket().shutdownInput();
            } catch (ClosedChannelException ignored) {

            } catch (IOException e) {
                Jvm.debug().on(getClass(), e);
            }

            try {
                clientChannel.socket().shutdownOutput();
            } catch (ClosedChannelException ignored) {

            } catch (IOException e) {
                Jvm.debug().on(getClass(), e);
            }

            Closeable.closeQuietly(clientChannel);

            this.clientChannel = null;

            if (LOG.isDebugEnabled())
                Jvm.debug().on(getClass(), "closing", new StackTrace("only added for logging - please ignore !"));

            @NotNull final TcpSocketConsumer tcpSocketConsumer = this.tcpSocketConsumer;

            tcpSocketConsumer.tid = 0;
            tcpSocketConsumer.omap.clear();

            onDisconnected();

        }
    }
539024
@Override
    public void afterConnectionClosed(final WebSocketSession webSocketSession, final CloseStatus status) {
        logger.debug("[afterConnectionClosed] id = ", webSocketSession.getId());
        this.session = null;

        if (connectionListener != null) {
            connectionListener.onConnectionClosed();
        }
    }
568724
def socket_close(self):
        """"""
        if self.sock != NC.INVALID_SOCKET:
            self.sock.close()
        self.sock = NC.INVALID_SOCKET
76295
private void closeServerSocket() {
       getLogger().debug("{} closing server socket", getName());

       try {
         if (serverSocket != null) {
           serverSocket.close();
         }
       } catch (Exception e) {
         // ignore for now
       }

       serverSocket = null;
     }
539677
def handle_ConnectionClose(self, frame):
        
        # Notify server we are OK to close.
        self.sender.send_CloseOK()

        exc = ConnectionClosed(frame.payload.reply_text,
                               frame.payload.reply_code)
        self._close_all(exc)
        # This will not abort transport, it will try to flush remaining data
        # asynchronously, as stated in `asyncio` docs.
        self.protocol.close()
632237
def close_websockets(self):
		
		self.log.info("Websocket Teardown called")
		for key in list(self.soclist.keys()):
			if self.soclist[key]:
				self.soclist[key].close()
			self.soclist.pop(key)
1308730
void onClose(AbstractSocket socket) {
		synchronized(sockets) {
			if(sockets.remove(socket.getId()) == null) throw new AssertionError("Socket not part of this context.  onClose called twice?");
		}
	}
335850
public void disconnect() {
        if (readyState == ReadyState.OPEN) {
            // readyState should be set to ReadyState.CLOSED ONLY AFTER the
            // the WebSocket has been successfully closed in
            // socketClosedHandler().
            this.closeConnection(0, "", 0, 0, null, null);
        } else if (readyState == ReadyState.CONNECTING) {
            socketClosedHandler();
        }
    }
493530
def catch_websocket_connection_errors():
  """"""
  try:
    yield
  except websocket.WebSocketConnectionClosedException:
    raise ConnectionError("Connection already closed. SC2 probably crashed. "
                          "Check the error log.")
  except websocket.WebSocketTimeoutException:
    raise ConnectionError("Websocket timed out.")
  except socket.error as e:
    raise ConnectionError("Socket error: %s" % e)
395526
def is_closing(self) -> bool:
        
        return self.stream.closed() or self.client_terminated or self.server_terminated
478175
async def poll_event(self):
        
        try:
            msg = await self.recv()
            await self.received_message(msg)
        except websockets.exceptions.ConnectionClosed as exc:
            if self._can_handle_close(exc.code):
                log.info('Websocket closed with %s (%s), attempting a reconnect.', exc.code, exc.reason)
                raise ResumeWebSocket(self.shard_id) from exc
            else:
                log.info('Websocket closed with %s (%s), cannot reconnect.', exc.code, exc.reason)
                raise ConnectionClosed(exc, shard_id=self.shard_id) from exc
976480
void connectionCloses(final SynchronizeFXTomcatConnection connection) {
        LOG.info("Client connection closed.");
        synchronized (connections) {
            final ExecutorService executorService = connectionThreads.get(connection);
            if (executorService != null) {
                executorService.shutdown();
            }
            connectionThreads.remove(connection);
            connections.remove(connection);
        }
    }
1189719
function() {
        if(this._conn.connected && !this._conn.disconnecting) {
            Strophe.error("Websocket closed unexcectedly");
            this._conn._doDisconnect();
        } else {
            Strophe.info("Websocket closed");
        }
    }