Connection failed
193794
def clientConnectionFailed(self, connector, reason):
        
        print('. Reason:', reason)        
        ReconnectingClientFactory.clientConnectionFailed(self, connector, reason)
823846
def connection_errors
      [
        Redis::BaseConnectionError,
        Redis::TimeoutError,
        IOError,
        Timeout::Error,
        Errno::EADDRNOTAVAIL,
        Errno::EAGAIN,
        Errno::EBADF,
        Errno::ECONNABORTED,
        Errno::ECONNREFUSED,
        Errno::ECONNRESET,
        Errno::EHOSTUNREACH,
        Errno::EINVAL,
        Errno::ENETUNREACH,
        Errno::EPIPE,
      ]
    end
1319412
public void reconnectFailedConnection(SearchFilter searchFilter) throws SQLException {
    if (!searchFilter.isInitialConnection()
        && (isExplicitClosed()
        || (searchFilter.isFineIfFoundOnlyMaster() && !isMasterHostFail())
        || searchFilter.isFineIfFoundOnlySlave() && !isSecondaryHostFail())) {
      return;
    }
    //check if a connection has been retrieved by failoverLoop during lock
    if (!searchFilter.isFailoverLoop()) {
      try {
        checkWaitingConnection();
        if ((searchFilter.isFineIfFoundOnlyMaster() && !isMasterHostFail())
            || searchFilter.isFineIfFoundOnlySlave() && !isSecondaryHostFail()) {
          return;
        }
      } catch (ReconnectDuringTransactionException e) {
        //don't throw an exception for this specific exception
        return;
      }
    }

    currentConnectionAttempts.incrementAndGet();
    resetOldsBlackListHosts();

    //put the list in the following order
    // - random order not blacklist and not connected host
    // - random order blacklist host
    // - connected host
    List<HostAddress> loopAddress = new LinkedList<>(urlParser.getHostAddresses());
    loopAddress.removeAll(getBlacklistKeys());
    Collections.shuffle(loopAddress);
    List<HostAddress> blacklistShuffle = new LinkedList<>(getBlacklistKeys());
    blacklistShuffle.retainAll(urlParser.getHostAddresses());
    Collections.shuffle(blacklistShuffle);
    loopAddress.addAll(blacklistShuffle);

    //put connected at end
    if (masterProtocol != null && !isMasterHostFail()) {
      loopAddress.remove(masterProtocol.getHostAddress());
      loopAddress.add(masterProtocol.getHostAddress());
    }

    if (secondaryProtocol != null && !isSecondaryHostFail()) {
      loopAddress.remove(secondaryProtocol.getHostAddress());
      loopAddress.add(secondaryProtocol.getHostAddress());
    }

    if ((isMasterHostFail() || isSecondaryHostFail())
        || searchFilter.isInitialConnection()) {
      //while permit to avoid case when succeeded creating a new Master connection
      //and ping master connection fail a few millissecond after,
      //resulting a masterConnection not initialized.
      do {
        MastersSlavesProtocol.loop(this, globalInfo, loopAddress, searchFilter);
        //close loop if all connection are retrieved
        if (!searchFilter.isFailoverLoop()) {
          try {
            checkWaitingConnection();
          } catch (ReconnectDuringTransactionException e) {
            //don't throw an exception for this specific exception
          }
        }
      } while (searchFilter.isInitialConnection()
          && !(masterProtocol != null || (urlParser.getOptions().allowMasterDownConnection
          && secondaryProtocol != null)));

      if (searchFilter.isInitialConnection() && masterProtocol == null && currentReadOnlyAsked) {
        currentProtocol = this.secondaryProtocol;
        currentReadOnlyAsked = true;
      }

    }

  }
341785
@Override
    public HttpResponse loginFailed(ServiceRequestContext ctx, AggregatedHttpMessage req,
                                    @Nullable MessageContext<Response> message, Throwable cause) {
        return HttpResponse.of(HttpStatus.UNAUTHORIZED, MediaType.HTML_UTF_8,
                               "<html><body>Login failed.</body></html>");
    }
665372
private function connect()
    {
        $headers = [];
        if ($this->lastId) {
            $headers['Last-Event-ID'] = $this->lastId;
        }

        $this->response = $this->client->request('GET', $this->url, [
            'stream' => true,
            'headers' => $headers,
        ]);

        if ($this->response->getStatusCode() == 204) {
            throw new RuntimeException('Server forbid connection retry by responding 204 status code.');
        }
    }
465802
private function _connect() 
    {

        if ($this->config['host'] && $this->config['port']) {
            // establish the memcache connection
            $this->memcache = new Memcache;
            $this->memcache->pconnect(
            	$this->config['host'], 
                $this->config['port']
            );

        } else {
            throw new Exception('Insufficient connection parameters');
        }
    }
599868
def connect(self):
        """"""
        log.info('Connecting socket on %s:%d' % (self.server, self.port))
        tries = 0
        while not self._socket and tries < 10:
            try:
                time.sleep(.2 * tries)
                self._socket = Socket((self.server, self.port))
            except socket.error:
                tries += 1
                log.warning(
                    'You must start/install wdb.server '
                    '(Retrying on %s:%d) [Try #%d/10]' %
                    (self.server, self.port, tries)
                )
                self._socket = None

        if not self._socket:
            log.warning('Could not connect to server')
            return

        Wdb._sockets.append(self._socket)
        self._socket.send_bytes(self.uuid.encode('utf-8'))
1048822
public function connect()
    {
        try {
            $this->_connection = new PDO(
                $this->_type .":host=". $this->_host .";dbname=". $this->_database .";port=". $this->_port,
                $this->_username,
                $this->_password
            );
        } catch(PDOException $e) {
            $code    = $e->getCode();
            $message = $e->getMessage();

            throw new ConnectionFailed($code, $message);
        }
    }
395711
private void connectionFailed() {
        // Send a failure message back to the Activity
        Message msg = mHandler.obtainMessage(ISOBlueDemo.MESSAGE_TOAST);
        Bundle bundle = new Bundle();
        bundle.putString(ISOBlueDemo.TOAST, "Unable to connect device");
        msg.setData(bundle);
        mHandler.sendMessage(msg);

        // Start the service over to restart listening mode
        BluetoothService.this.start();
    }
499919
function onConnect(err) {
    if (err) {
      DEBUG("connect error", err)
      return cb(err)
    }

    DEBUG("connected")

    channel.sendMessage({
      type: "request",
      name: "connect",
      to:   "server",
      id:   "0",
      body: {
        key: config.key
      }
    })
  }
1277806
public void connectionFailed (
        String ident, boolean readOnly, Connection conn, SQLException error)
    {
        String mapkey = ident + ":" + readOnly;
        Mapping conmap = _idents.get(mapkey);
        if (conmap == null) {
            log.warning("Unknown connection failed!?", "key", mapkey);
        } else {
            conmap.closeConnection(ident);
        }
    }
52802
private void connect(DeviceProxy device_proxy, String attributeName, String eventName, DeviceData deviceData) throws DevFailed {
        String deviceName = device_proxy.name();
        String adm_name = null;
        try {
            adm_name = device_proxy.adm_name();
        } catch (DevFailed e) {
            Except.throw_event_system_failed("API_BadConfigurationProperty",
                    "Can't subscribe to event for device " + deviceName
                            + "\n Check that device server is running...",
                    "NotifdEventConsumer.connect");
        }
        String channelName = adm_name;
        // If no connection exists to this channel, create it
        Database dbase = null;
        if (!channel_map.containsKey(channelName)) {
            if (device_proxy.use_db())
                dbase = device_proxy.get_db_obj();
            ConnectionStructure connectionStructure =
                    new ConnectionStructure(device_proxy.get_tango_host(), channelName,
                        deviceName, attributeName, eventName, dbase, deviceData, false);
            connect_event_channel(connectionStructure);
        } else if (device_proxy.use_db()) {
            dbase = device_proxy.get_db_obj();
        }
        EventChannelStruct eventChannelStruct = channel_map.get(channelName);
        eventChannelStruct.adm_device_proxy = device_proxy.get_adm_dev();
        eventChannelStruct.use_db = device_proxy.use_db();
        eventChannelStruct.dbase = dbase;

        device_channel_map.put(deviceName, channelName);
    }
565210
function() {
        try {
          var server = {
            "host": params.host,
            "port": params.port,
            "timeout": params.timeout || 20000,
            "connectHeaders": {
              "host": "/",
              "login": params.username,
              "passcode": params.password,
              "heart-beat": "5000, 5000"
            }
          };

          var servers = [server];

          var reconnectOptions = {
            'maxReconnects': 20
          };

          var manager = new Stompit.ConnectFailover(servers, reconnectOptions);

          manager.connect(function(error, stompClient, reconnect) {
            if (error) {
              fireEvent("error", {
                errorCode: error.code,
                errorMessage: error.message,
                errorEvent: error
              });

              return;
            }

            client = stompClient;

            client.on('error', function(error) {
              fireEvent("error", {
                errorCode: 999,
                errorMessage: "ActiveMQ client has had an error",
                errorEvent: error
              });
              reconnect();
            });

            fireEvent("init");
          });

        } catch (error) {
          console.error(error);
        }
      }
173706
@Override
    public void unexportServer(final String serverName) throws DevFailed {
        final DeviceData argin = new DeviceData();
        argin.insert(serverName);
        database.command_inout("DbUnExportServer", argin);
    }
683806
function(callback) {
      self._getConnection(function(err, connection) {
        if (err) {
          callback(new Error('Unable to establish connection with the master ' +
                             'process'));
          return;
        }

        self._connection = connection;
        callback();
      });
    }
129034
public void init(final Connection connection) throws DevFailed {
		// Check Tango Host Properties (host name, port number)
		// ------------------------------------------------------------
		connection.url = new TangoUrl();
		connection.setDevice_is_dbase(true);
		connection.transparent_reconnection = true; // Always true for Database
		//connection.url.trace();

		ApiUtil.get_orb();
		connect_to_dbase(connection);
		connection.devname = connection.device.name();
		connection.setAlready_connected(true);
    }
83583
public void connectionFailed (String ident, boolean readOnly, Connection conn,
                                  SQLException error)
    {
        try {
            conn.close();
        } catch (Exception e) {
            log.warning("Failure closing failed connection",
                        "ident", ident, "ro", readOnly, "conn", conn, e);
        }
    }