mphp
New member
Hi everyone ツ. I have an annoying error in my php logs thats constant and annoying. Basically developer is out of business and their server is down so anytime the extension tries to connect to them I get log errors...
Can someone help me modify their PHP code to exclude this error? I am so appreciative of any help you guys can provide. Beginner in PHP and really don't want to break the extension if I try to modify the code myself...
PHP Warning: stream_socket_client(): unable to connect to tcp://46.101.32.100:443 (Connection timed out) in /lib/browser.php on line 489
This is the code from line 489:
FULL CODE:
Can someone help me modify their PHP code to exclude this error? I am so appreciative of any help you guys can provide. Beginner in PHP and really don't want to break the extension if I try to modify the code myself...
PHP Warning: stream_socket_client(): unable to connect to tcp://46.101.32.100:443 (Connection timed out) in /lib/browser.php on line 489
This is the code from line 489:
Code:
$this->sock = stream_socket_client("tcp://$this->addr:$this->port", $errno, $errorMessage, $this->timeout, STREAM_CLIENT_CONNECT, $ctx);
FULL CODE:
Code:
public function connect() {
$reuseKey = implode(':', array($this->addr, $this->port));
if (isset(self::$connections[$reuseKey])) {
foreach (self::$connections[$reuseKey] as $sock) {
if (!in_array($sock, NitroBrowser::$free_connections)) continue;
$this->sock = $sock;
if ($this->isConnectionValid()) {// check if the connection is still alive
return;
} else {
$this->disconnect(); // Remove the inactive connection
}
}
}
if (stripos(ini_get('disable_functions'), 'stream_socket_client') !== FALSE) {
throw new RuntimeException("stream_socket_client is disabled.");
}
$ctxOptions = array(
"ssl" => array(
"verify_peer" => false,
"verify_peer_name" => false,
"allow_self_signed" => true,
"SNI_enabled" => true,
"peer_name" => $this->host
)
);
if (version_compare(PHP_VERSION, '5.6.0', '<')) {
$ctxOptions["ssl"]["SNI_server_name"] = $this->host;
}
$ctx = stream_context_create($ctxOptions);
$errno = $errorMessage = NULL;
$connectionStartTime = microtime(true);
$this->sock = stream_socket_client("tcp://$this->addr:$this->port", $errno, $errorMessage, $this->timeout, STREAM_CLIENT_CONNECT, $ctx);
$this->initial_connection = microtime(true) - $connectionStartTime;
if($this->sock === false) {
throw new SocketOpenException('Unable to open socket to: ' . $this->host .' on port ' . $this->port);
}
if ($this->connection_reuse) {
if (!isset(self::$connections[$reuseKey])) {
self::$connections[$reuseKey] = array();
}
self::$connections[$reuseKey][] = $this->sock;
}
NitroBrowser::$secure_connections[(int)$this->sock] = false;
}