无法连接到xxxxx.com端口8280:连接被拒绝“

Here I have tried to get curl request and it works on some servers and did not work in some servers, but it works in local host. when I print the error msg it says

"Failed to connect to api.lankagate.gov.lk port 8280: Connection refused".

Here is the my function:

function get_on_going_vehicle_number() {
$vehicle_category = 1;

    $xml_data = '<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v1="http://schemas.conversesolutions.com/xsd/dmticta/v1">

 <soapenv:Header/>
 <soapenv:Body>
 <v1:GetOnGoingVehicleNo>
 <v1:vehicleCategory>' . $vehicle_category . '</v1:vehicleCategory>
 </v1:GetOnGoingVehicleNo>
 </soapenv:Body>
</soapenv:Envelope>';
$URL = "http://api.lankagate.gov.lk:8280/GetOnGoingVehicleNoDMT/1.0";

    $ch = curl_init($URL);


    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        'Content-Type: text/xml',
        'Authorization: Bearer 7655a410-d019-3f09-b214-08c40e737af0'
    ));

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_PORT,8280);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $output = curl_exec($ch);

    if (curl_error($ch)) {
    $error_msg = curl_error($ch);
    echo $error_msg;

     }

    return $output;
    curl_close($ch);

}

we try to telnet:

working server: > telnet api.lankagate.gov.lk 8280 Trying 43.224.126.66...
Connected to api.lankagate.gov.lk.
Escape character is '^]'.
Connection closed by foreign host. Non working server: 
user@dwp-s01:~$ telnet api.lankagate.gov.lk 8280 

Not working server:

Trying 192.168.12.117... 
telnet: Unable to connect to remote host: Connection refused 
user@dwp-s01:~$ 

It'tries to different Ip : 192.168.12.117 Please give me a solution

There could be multiple issues here.

  1. api.lankagate.gov.lk has firewall enabled.
  2. Port 8280 is not free.

I guess you can't disable the firewall on api.lankagate.gov.lk. So, please try some other port.

192.168.12.117 seems local network.

So, you might have pointed this ip in your host file and have to remove that

Example:

c:\Windows\System32\Drivers\etc\hosts or /etc/hosts

192.168.12.117 api.lankagate.gov.lk

Or your network router or proxy (192.168.12.117) blocking you to connect that.