DingDongmaster the connection is open
434826
async def on_open(self):
        """"""

        self.__ensure_barrier()
        while self.connected:
            try:
                if self.__lastping > self.__lastpong:
                    raise IOError("Last ping remained unanswered")

                self.send_message("2")
                self.send_ack()
                self.__lastping = time.time()
                await asyncio.sleep(self.ping_interval)
            except Exception as ex:
                LOGGER.exception("Failed to ping")
                try:
                    self.reraise(ex)
                except Exception:
                    LOGGER.exception(
                        "failed to force close connection after ping error"
                    )
                break
1133871
@Override
	protected void openConnectionInternal() throws ConnectionException, AuthenticationException {
		if (checkoutDirectory == null) {
			checkoutDirectory = createCheckoutDirectory();
		}

		if (checkoutDirectory.exists() && safeCheckout) {
			removeCheckoutDirectory();
		}

		checkoutDirectory.mkdirs();
	}
179299
def open(self):
        """"""
        try:
            connection = self.transport_class(
                host=self.hostname,
                username=self.username,
                password=self.password,
                timeout=self.timeout,
                **self.eapi_kwargs
            )

            if self.device is None:
                self.device = pyeapi.client.Node(connection, enablepwd=self.enablepwd)
            # does not raise an Exception if unusable

            # let's try to run a very simple command
            self.device.run_commands(["show clock"], encoding="text")
        except ConnectionError as ce:
            # and this is raised either if device not avaiable
            # either if HTTP(S) agent is not enabled
            # show management api http-commands
            raise ConnectionException(py23_compat.text_type(ce))
185151
def on_welcome(self, connection, event):
        
        connection.join(self.channel, key=settings.IRC_CHANNEL_KEY or "")
116224
async def connect(self):
        
        await self._sender.connect(self._connection(
            self.session.server_address,
            self.session.port,
            self.session.dc_id,
            loop=self._loop,
            loggers=self._log,
            proxy=self._proxy
        ))
        self.session.auth_key = self._sender.auth_key
        self.session.save()

        await self._sender.send(self._init_with(
            functions.help.GetConfigRequest()))

        self._updates_handle = self._loop.create_task(self._update_loop())
370516
public boolean connectIfNeeded() {
        if (getDDP().getState() == CONNSTATE.Disconnected) {
            // make connection to Meteor server
            getDDP().connect();
            return true;
        } else if (getDDP().getState() == CONNSTATE.Closed) {
           // try to reconnect w/ a new connection
            createDDPClient();
            getDDP().connect();
        }
        return false;
    }
351626
public MqttAsyncClient connectBroker() {
        LOG.info(String.format("mqtt=======客户端%s与rabbitMQ server: %s 准备建立连接,userName = %s", getMqttClientId(), JSON.toJSONString(serverURIs), userName));
        try {
            sampleClient = new MqttAsyncClient("tcp://overriddenByMqttConnectOptions.setServerURIs:1883", getMqttClientId(), persistence);
            connOpts = new MqttConnectOptions();
            connOpts.setAutomaticReconnect(true);
            connOpts.setServerURIs(serverURIs);
            connOpts.setUserName(userName);
            connOpts.setPassword(getPwd());
            connOpts.setCleanSession(cleanSession);
            connOpts.setMaxInflight(1000 /**默认的值是10,对于我们来说这个值太小!*/);
            connOpts.setKeepAliveInterval(keepAliveInterval);
            sampleClient.setCallback(getCallback(this));
            sampleClient.connect(connOpts).waitForCompletion(60 * 1000);
            LOG.info(String.format("mqtt=======客户端%s与rabbitMQ server: %s 建立连接完成,userName = %s", getMqttClientId(), JSON.toJSONString(serverURIs), userName));
            return sampleClient;
        } catch (MqttException me) {
            throw new RuntimeException(String.format("mqtt=======客户端%s与rabbitMQ server: %s 连接失败!!! userName = %s", getMqttClientId(), JSON.toJSONString(serverURIs), userName), me);
        }
    }
775104
private void startConnecting()
    {
        //  Open the connecting socket.
        try {
            boolean rc = open();

            //  Connect may succeed in synchronous manner.
            if (rc) {
                handle = ioObject.addFd(fd);
                connectEvent();
            }
            //  Connection establishment may be delayed. Poll for its completion.
            else {
                handle = ioObject.addFd(fd);
                ioObject.setPollConnect(handle);
                socket.eventConnectDelayed(addr.toString(), -1);
            }
        }
        catch (RuntimeException | IOException e) {
            //  Handle any other error condition by eventual reconnect.
            if (fd != null) {
                close();
            }
            addReconnectTimer();
        }
    }
874418
def connect(self, ctrl):
        """"""
        if self.prompt:
            self.prompt_re = self.driver.make_dynamic_prompt(self.prompt)
        else:
            self.prompt_re = self.driver.prompt_re

        self.ctrl = ctrl
        if self.protocol.connect(self.driver):
            if self.protocol.authenticate(self.driver):
                self.ctrl.try_read_prompt(1)
                if not self.prompt:
                    self.prompt = self.ctrl.detect_prompt()

                if self.is_target:
                    self.update_config_mode()
                    if self.mode is not None and self.mode != 'global':
                        self.last_error_msg = "Device is not in global mode. Disconnected."
                        self.chain.disconnect()
                        return False

                self.prompt_re = self.driver.make_dynamic_prompt(self.prompt)
                self.connected = True

                if self.is_target is False:
                    if self.os_version is None:
                        self.update_os_version()

                    self.update_hostname()
                else:
                    self._connected_to_target()
                return True

        else:
            self.connected = False
            return False
342277
def on_connection_open(self, unused_connection):
        
        self._logger.info('Connection opened')
        self.add_on_connection_close_callback()
        self.open_channel()
603724
public function beginTransaction()
    {
        // auto reconnect
        $this->connect();
        
        $this->isTransaction = true;
        $this->connection->autocommit(false);//关闭自动提交
        return ;
    }
765870
function Connect()
	{
		$this->handler->Log(DBH_LOG_INFO, "Opening Connection...");
		if ($this->dbopen)
		{
			$this->handler->Log(DBH_LOG_WARNING, "Connection Already Open");
		}
		else
		{
			$this->adapter = new DataAdapter($this->csetting);
			
			try {
				$this->adapter->Open();
			}
			catch (Exception $ex) {
				$this->handler->Crash(DatabaseException::$CONNECTION_ERROR,$ex->getMessage());
			}

			$this->handler->Log(DBH_LOG_INFO, "Connection Open");
			$this->dbopen = true;
		}
	}
18090
function() {
        clearInterval(this._checkConnectionTimer);
        this._checkConnectionTimer = undefined;
        this.muc.joinedRooms = {};
        this._isLogout = true;
        this.helpers.setUserCurrentJid('');

        if (Utils.getEnv().browser) {
            this.connection.flush();
            this.connection.disconnect();
        } else {
            this.Client.end();
        }
    }
1333707
function connect() {
  console.log('Connecting client: ' + clientId + ' to url:"' + url + '"');
  client = mqtt.connect(url, { 'clientId': clientId });
}
956966
function connect () {
  // connection
  if (!alreadyConnectedOnce) {
    if (connectedPromise === null) connection = createConnection()
    var url = AppConfig.apiUrl + 'websocket/chat'
    if (accessToken) {
      token = accessToken
      url += '?access_token=' + accessToken
    }
    socket = new SockJS(url)
    stompClient = webstomp.over(socket)
    // stompClient.debug = null
    console.tron.log(`Connecting to ${url}`)
    var headers = {}
    stompClient.connect(headers, onConnect, onError)
    alreadyConnectedOnce = true
  }
}
283611
def open_connection(request)
      connection = ConnectionAdapters.establish_connection(request, dispatcher)

      assign_connection_id connection
      register_user_connection connection

      connections[connection.id] = connection

      info "Connection opened: #{connection}"
      connection.rack_response
    end
33561
def connect(self):
        
        self.socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            self.socket.connect((self.host, self.port))
        except socket.error as (err, msg):
            self.connected = False
            raise ScratchError("[Errno %d] %s" % (err, msg))
        self.connected = True