Changeset b757e0e for src


Ignore:
Timestamp:
Aug 30, 2015, 8:56:51 PM (11 years ago)
Author:
Joachim Langenbach <joachim.langenbach@…>
Branches:
master
Children:
7e8f16c
Parents:
552da81
Message:

IpGeoLocator fetches timeout exception now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/webservice/htdocs/SiWeather/Webservice/IpGeoLocator.php

    r552da81 rb757e0e  
    4646                        [
    4747                                "base_uri" => $baseUrl,
    48                                 "timeout" => 5.0,
     48                                "timeout" => 1.0,                                                               # we need a very small timeout here, because otherwise the request of our caller function may time out!
    4949                                "http_errors" => false,
    5050                        ]
    5151                );
    52                 $response = $client->get("/json/". $ip);
     52                try{
     53                        $response = $client->get("/json/". $ip);
     54                }
     55                catch(\GuzzleHttp\Exception\ConnectException $exception){
     56                        $errorMessage = "IpGeoLocator: Fetched connect exception (mostly timeout): ". $exception->getMessage();
     57                        error_log($errorMessage);
     58                        return null;
     59                }
    5360                if(is_null($response)){
    5461                        $errorMessage = "IpGeoLocator: Failed to fetch ip";
     62                        error_log($errorMessage);
    5563                        return null;
    5664                }
Note: See TracChangeset for help on using the changeset viewer.