본문 바로가기
개발/php

stream_socket_client() php_network_getaddresses getaddrinfo failed name or service not known

by 향유 2021. 1. 12.

php snoopy 라이브러리로 크롤링기능을 개발하여 서버에 업로드 하였다.

개발 서버에서는 정상 작동하던 프로그램이 서버이전시 다음과 같은 error 메세지를 표시하며 작동하지 않았다.

stream_socket_client() php_network_getaddresses getaddrinfo failed name or service not known

 

원인

1)서버 접근 권한없음

 

2)서버에서 요청이 나갈 권한이 없음.

 

 

해결 방법

1) 본인의 포트와 호스트를 확인하여 서버 접속 권한을 얻으면된다.

 

2) 프록시 우회기능을 사용한다.

snoopy의 경우 38~39line

    var $proxy_host = ""; // proxy host to use
    var $proxy_port = ""; // proxy port to use

 

이곳에 우회 ip와 포트를 입력하면

아래 소스 코드의 연결부분에서 프록시를 반영하여 우회 접속이 된다.

    function _connect(&$fp)
    {
        if (!empty($this->proxy_host) && !empty($this->proxy_port)) {
            $this->_isproxy = true;

            $host = $this->proxy_host;
            $port = $this->proxy_port;

            if ($this->scheme == 'https') {
                trigger_error("HTTPS connections over proxy are currently not supported", E_USER_ERROR);
                exit;
            }
        } else {
            $host = $this->host;
            $port = $this->port;
        }

        ....

 

HTTPS connections over proxy are currently not supported error 발생시 해결방법

:enjoyk.tistory.com/80

댓글