Php fsockopen connection timed out

Email problem: Connection timed out

Opencart version is 2.2.0.0
In my pc, it works fine. I had also build some opencart 2.2.0.0 projects, no problem.
But today the problem happens in my new project, a remote server, it’s vps, cPanel.

When I submit the register form, the page says:

Warning: fsockopen(): unable to connect to smtp.gmail.com:465 (Connection timed out) in /home/xxx/public_html/system/library/mail.php on line 167
$handle = fsockopen($hostname, $this->smtp_port, $errno, $errstr, $this->smtp_timeout);

Then I start to figure out. First, I put the following two lines before line 167, get the same error, didn’t see number 123.

$handle = fsockopen('ssl://smtp.gmail.com', 465, $errno, $errstr, 20); echo "
".print_r(123, 1)."

"; exit;

OK, then I tried many places in many files:
/catalog/model/account/customer.php
/catalog/controller/account/register.php
/index.php
/system/framework.php

$handle = fsockopen('ssl://smtp.gmail.com', 465, $errno, $errstr, 20); // Dispatch $controller->dispatch(new Action($config->get('action_router')), new Action($config->get('action_error'))); $handle = fsockopen('ssl://smtp.gmail.com', 465, $errno, $errstr, 20); echo "
".print_r(123, 1)."

"; exit;

Re: Email problem: Connection timed out

Post by MarketInSG » Mon Mar 06, 2017 10:54 pm

Re: Email problem: Connection timed out

Post by arhatron » Mon Mar 06, 2017 10:55 pm

The remote server shows failed. I thought it’s ok! So this is nothing to do with opencart.
I guess the remote server has blocked the outgoing 465 port.

Re: Email problem: Connection timed out

Post by arhatron » Mon Mar 06, 2017 11:00 pm

One minute ago, I was still finding the answer. After I reply my own question, I see your reply.
Why you didn’t tell me earlier. I should use if else to echo >_

I was misguided by the error message.
This file /catalog/controller/startup/error.php do things to php error message.
The route of $action, it was
startup/startup
startup/error
start/event
.
I thought something wrong with startup/event, because before this, no error message.
But actually, the problem occurs at the first very begging.

registry->set('log', new Log($this->config->get('error_filename'))); set_error_handler(array($this, 'handler')); > public function handler($code, $message, $file, $line) < // error suppressed with @ if (error_reporting() === 0) < return false; >switch ($code) < case E_NOTICE: case E_USER_NOTICE: $error = 'Notice'; break; case E_WARNING: case E_USER_WARNING: $error = 'Warning'; break; case E_ERROR: case E_USER_ERROR: $error = 'Fatal Error'; break; default: $error = 'Unknown'; break; >if ($this->config->get('error_display')) < echo '' . $error . ': ' . $message . ' in ' . $file . ' on line ' . $line . ''; > if ($this->config->get('error_log')) < $this->log->write('PHP ' . $error . ': ' . $message . ' in ' . $file . ' on line ' . $line); > return true; > > 

Источник

Solving the PHP Warning: fsockopen(): unable to connect (Connection timed out)

If you’ve worked with APIs you’ve probably gotten this error and know how annoying it is. All because the native function never returns any actionable error for its request timing out. The best way to detect if the fsockopen() function request is timing out is to use a error control operator. The idea is to suppress the timeout warning with a @ prefix, so the function only returns true if it completes its cycle/request. You can review the example PHP code below.

 if($fp = @fsockopen($host, $port, $errno, $errstr, $timeout)) < return true; >else

Issues? leave your questions.

Published by

Miguel

I’m a bilingual Network Engineer. I have over 20 Years of Professional experience in Computer Science & Information Technology. I currently own and operate Web Semantics (www.websemantics.com) in Vancouver, Washington. I provide bilingual (English & Spanish) enterprise-level IT support to small and medium-sized businesses across the West Coast. *** Soy un ingeniero de redes bilingüe. Tengo más de 20 años de experiencia profesional en ciencias de la computación y tecnología de la información. Actualmente poseo y opero Web Semantics (www.websemantics.com) en Vancouver, Washington. Proporciono soporte de IT/Informática bilingüe (inglés y español) a nivel empresarial a pequeñas y medianas empresas en toda la costa oeste.View all posts by Miguel

Leave a Reply Cancel reply

You must be logged in to post a comment.

Источник

Как решить [Предупреждение: fsockopen (): невозможно подключиться]?

Я хочу проверить, что мой сервер Ubuntu Server 14.04 LTS находится в сети или нет на моем сервере хостинга. Мой сервер имеет IP-адрес, но у моего сервера хостинга есть домен. Для этого я использовал приведенный ниже код на моем сервере хостинга для проверки того, что мой сервер подключен к сети или нет.

После добавления вышеуказанного кода в php файл моего общего хостинга, когда я его запустил, я получил следующую ошибку. Warning: fsockopen(): unable to connect to XX.XX.XX.XX:7550 (Connection timed out) in/home/USERNAME/public_html/index.php on line 4 110: Connection timed out SERVER IS DOWN Теперь кто-нибудь скажет мне, что allow_url_fopen = On на моем сервере хостинга или нет, тогда я проверил файл php.ini моего хостинга и там он включен. Теперь, когда я искал помощь по всему, кто-то еще сказал мне, чтобы проверить, что оба (мой общий хостинг-сервер и мой сервер) имеют fsockopen() ON или нет. Затем я написал приведенный ниже код в php файле и запускался на обоих серверах.

После запуска вышеуказанного.php файла на обоих серверах я получил тот же результат на обоих серверах. fsockopen Is Working Perfectly. Важное примечание. Имейте в виду, что мой IP-адрес сервера остается активным, так как я использую много компьютеров на этом IP-адресе, но мой сервер выключен. Также я могу открыть http://XX.XX.XX.XX:7550 в своем веб-браузере, используя прокси-сервер.

Connection timed out обычно указывает на брандмауэр или ответ от удаленной стороны, который занимает слишком много времени.

Вы уверены, что ваш брандмауэр правильно перенаправил TCP-порт 7550 на целевой сервер? Потому что обычно веб-сервер работает в порту 80, который открыт, если вы можете заходить на веб-сайты.

@GeraldSchneider Я знаю, в чем смысл Connection timed out http://XX.XX.XX.XX:7550 Connection timed out но я открываю http://XX.XX.XX.XX:7550 на прокси-сервере, тогда для открытия браузера требуется всего 1 секунда.

Если вы хотите сетевой обмен данными с расширенными функциональными возможностями, используйте socket_create вместо fsockopen .

@DanFromGermany Я новичок в этой области. Так что вы можете поделиться всем кодом в ответе. Я получил все вышеуказанные коды из Интернета.

Я не получаю платное кодирование за вопросы stackoverflow. Вы должны прочитать документацию и извлечь уроки из нее.

Источник

Читайте также:  Функция strpos в php
Оцените статью