Schedule connection reopen.
@param conn The connection.
163236
private void reopen(final ConnectionPoolConnection conn) {

      if(isActive) {
         if(conn.reopenAttempts == 0) {
            conn.reopenAttempts++;
            reopenService.execute(new Reopener(conn));
         } else {
            long delayMillis = 100L * conn.reopenAttempts;
            if(delayMillis > maxReconnectDelayMillis) {
               delayMillis = maxReconnectDelayMillis;
            }
            conn.reopenAttempts++;
            reopenService.schedule(new Reopener(conn), delayMillis, TimeUnit.MILLISECONDS);
         }
      }
   }
646677
public void removeConnection(WebSocketConnection conn) {
        conns.remove(conn);
        for (IWebSocketDataListener listener : listeners) {
            listener.onWSDisconnect(conn);
        }
    }
1295695
protected void resumeSession (AuthRequest req, PresentsConnection conn)
    {
        // check to see if we've already got a connection object, in which case it's probably stale
        Connection oldconn = getConnection();
        if (oldconn != null && !oldconn.isClosed()) {
            log.info("Closing stale connection", "old", oldconn, "new", conn);
            // close the old connection (which results in everything being properly unregistered)
            oldconn.close();
        }

        // note our new auth request (so that we can deliver the proper bootstrap services)
        _areq = req;

        // start using the new connection
        setConnection(conn);

        // if a client connects, drops the connection and reconnects within the span of a very
        // short period of time, we'll find ourselves in resumeSession() before their client object
        // was resolved from the initial connection; in such a case, we can simply bail out here
        // and let the original session establishment code take care of initializing this resumed
        // session
        if (_clobj == null) {
            log.info("Rapid-fire reconnect caused us to arrive in resumeSession() before the " +
                     "original session resolved its client object " + this + ".");
            return;
        }

        // we need to get onto the dobj thread so that we can finalize resumption of the session
        _omgr.postRunnable(new Runnable() {
            public void run () {
                // now that we're on the dobjmgr thread we can resume our session resumption
                finishResumeSession();
            }
        });
    }
84593
async def shutdown(self, connmark = -1):
        '''
        
        '''
        if connmark is None:
            connmark = self.connmark
        self.scheduler.emergesend(ConnectionControlEvent(self, ConnectionControlEvent.SHUTDOWN, True, connmark))
310867
function ReconnectingConnection(id, connection) {
  this.id = id;
  this.connection = null;
  this.closed = false;
  this.queue = [];

  this.setConnection(connection);
}
1094483
def reconnect(self):
        """"""
        try:
            self.conn.close()
        except Exception,e:
            self.logger.warn(e)

        self.createConnection()

        return True
968022
function (conn, opts) {
            opts = opts || {};
            var s;
            if ((s = opts.prepare)) {
                return this.__logConnectionExecute(conn, comb("XA START %s").format(this.literal(s)));
            } else {
                return this._super(arguments);
            }
        }
1051362
public function onClose(Connection $conn)
    {
        $this->onPublishResponse($conn, "CONN_CLOSED", new NsqException("connection close, maybe disposable connection timeout"));

        if (!$conn->isDisposable()) {
            $this->lookup->removeConnection($conn);

            $remainConnNum = count($this->getNsqdConns());
            sys_echo("nsq({$conn->getAddr()}) producer onClose: there are $remainConnNum connections left alive");

            if ($this->lookup->isStopped()/* && $remainConnNum === 0*/) {
                return;
            }

            Task::execute($this->reconnectToNSQD($conn));
        }
    }
13890
public synchronized void connectionClosed (Connection conn)
    {
        // remove the session from the connection map
        PresentsSession session = _conmap.remove(conn);
        if (session != null) {
            log.debug("Unmapped session", "session", session, "conn", conn);
            // let the session know the connection went away
            session.wasUnmapped();

        } else {
            log.debug("Closed unmapped connection '" + conn + "'. " +
                    "Session probably not yet authenticated.");
        }
    }
443067
def release(self, conn):
        """"""
        self._pool_lock.acquire()
        self._pool.put(ConnectionWrapper(self._pool, conn))
        self._current_acquired -= 1
        self._pool_lock.release()
1267887
protected void reconnect() {
		disconnect().then(ok -> {
			logger.info("Trying to reconnect...");
			scheduler.schedule(this::connect, 5, TimeUnit.SECONDS);
		}).catchError(cause -> {
			logger.warn("Unable to disconnect from Redis server!", cause);
			scheduler.schedule(this::connect, 5, TimeUnit.SECONDS);
		});
	}
830723
public synchronized void connectionEstablished (
        PresentsConnection conn, Name authname, AuthRequest req, AuthResponse rsp)
    {
        String type = authname.getClass().getSimpleName();

        // see if a session is already registered with this name
        PresentsSession session = getClient(authname);

        if (session != null) {
            //log.info("Resuming session", "type", type, "who", authname, "conn", conn);
            session.resumeSession(req, conn);

        } else {
            log.info("Session initiated", "type", type, "who", authname, "conn", conn);
            // figure out our session class
            Class<? extends PresentsSession> sessionClass = null;
            for (SessionFactory factory : _factories) {
                if ((sessionClass = factory.getSessionClass(req)) != null) {
                    break;
                }
            }
            // create a new session and stick'em in the table
            session = _injector.getInstance(sessionClass);
            session.startSession(authname, req, conn, rsp.authdata);

            // map their session instance
            synchronized (_usermap) {
                // we refetch the authname from the session for use in the map in case it decides
                // to do something crazy like rewrite it in startSession()
                _usermap.put(session.getAuthName(), session);
            }
        }

        // map this connection to this session
        _conmap.put(conn, session);
    }
419029
private void executeReconnect() throws InterruptedException {
		// Close connection
		websocketEndpoint.close();

		// Store the reconnect time to prevent to much
		// reconnects in a short timeframe. Otherwise the
		// rate limit will apply and the reconnects are not successfully
		logger.info("Wait for next reconnect timeslot");
		eventsInTimeslotManager.recordNewEvent();
		eventsInTimeslotManager.waitForNewTimeslot();
		logger.info("Wait for next reconnect timeslot DONE");

		bitfinexApiBroker.reconnect();
	}
648774
@Override
	public void connectionEvent(Connection conn, Events type) {
		switch (type) {
		case CONNECTED:

			// The connection is permanently closed, either by manual action or
			// failed reconnects
			if (debug) {
				logger.info("NATS connection opened.");
			}
			break;

		case CLOSED:

			// The connection lost its connection, but may try to reconnect if
			// configured to
			logger.info("NATS connection closed.");
			if (started.get()) {
				reconnect();
			}
			break;

		case DISCONNECTED:

			// The connection was connected, lost its connection and
			// successfully reconnected
			if (debug) {
				logger.info("NATS pub-sub connection disconnected.");
			}
			break;

		case RECONNECTED:

			// The connection was reconnected and the server has been notified
			// of all subscriptions
			if (debug) {
				logger.info("NATS connection reconnected.");
			}
			break;

		case RESUBSCRIBED:

			// The connection was told about new servers from, from the current
			// server
			if (debug) {
				logger.info("NATS subscriptions re-established.");
			}
			break;

		case DISCOVERED_SERVERS:

			// Servers discovered
			if (debug) {
				logger.info("NATS servers discovered.");
			}
			break;

		default:
			break;
		}
	}
1365388
public void reconnect(DuplexConnection connection) {
    if (curConnection == null) {
      logger.debug("{} Resumable duplex connection started with connection: {}", tag, connection);
      state = State.CONNECTED;
      onNewConnection(connection);
    } else {
      logger.debug(
          "{} Resumable duplex connection reconnected with connection: {}", tag, connection);
      /*race between sendFrame and doResumeStart may lead to ongoing upstream frames
      written before resume complete*/
      dispatch(new ResumeStart(connection));
    }
  }
272205
private void closeConnection( IConnection conn )
    {
        try
        {
            if( conn != null && conn.isOpen() )
                conn.close();
        }
        catch ( OdaException e )
        {
            // ignore
            e.printStackTrace();
        }
    }
225662
private synchronized void reschedule(long millis) {
        currentFut = null;  // Remove current future.

        if (!closed) {
            SCHEDULER.schedule(this::refresh, millis, TimeUnit.MILLISECONDS);
        } else {
            try {
                underlying.close();
            } catch (Exception ex) {
                LOG.log(Level.WARNING, "failed to close resolver " + underlying.configString(), ex);
            }
        }
    }