PHP-数据导入Tally-超时错误

时间:2019-11-11 11:50:08

标签: php mysql curl tally

我想使用下面的代码将PHP连接到tally。但是当移至生产环境时会显示超时错误。但是当我在本地计算机上的计价器中运行代码时成功插入了数据显示错误无法连接到xxx.xxx.x.xx端口9000:连接超时出现了问题.....稍后再试

<?php
/* This is PHP code to insert an entry in Tally. All required XML tags by Tally are taken here in a string and name for Ledger is taken by posted value from HTML form. */
$requestXML = '<?xml version="1.0"?>
        <ENVELOPE>
<HEADER>
<TALLYREQUEST>Export Data</TALLYREQUEST>
</HEADER>
<BODY>
<EXPORTDATA>
<REQUESTDESC>
<STATICVARIABLES>

<!--To Fetch data in XML format-->
<SVEXPORTFORMAT>$$SysName:XML</SVEXPORTFORMAT>

<!--To Fetch data in HTML format, change the SVEXPORTFORMAT Tag value as -->
<!--$$SysName:HTML-->

</STATICVARIABLES>
<REPORTNAME>Balance Sheet</REPORTNAME>
</REQUESTDESC>
</EXPORTDATA>
</BODY>
</ENVELOPE>';

/* Actual code for importing goes here */
        $server = 'http://xxx.xxx.x.xxx:9000';
        $headers = array( "Content-type: text/xml" ,"Content-length: ".strlen($requestXML) ,"Connection: close" );

        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $server);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_TIMEOUT, 100000);
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXML);
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        $data = curl_exec($ch);

        if(curl_errno($ch))
        {
            print curl_error($ch);
            echo "  something went wrong..... try later";
        }
        else
        {
            echo " request accepted";
            print $data;
            curl_close($ch);
        }


?>

1 个答案:

答案 0 :(得分:1)

  1. http://xxx.xxx.x.xxx:9000-这是本地主机,例如127.0.0.1?如果 因此,您将无法从远程服务器访问它。
  2. 它看起来像一个LAN IP(例如192.168.0.104)。在这种情况下 可以通过LAN(同一网络,另一台计算机)进行访问,但是 不是来自远程服务器(不在同一LAN上)。
  3. 如果不是localhost / LAN IP,它是静态IP吗?我的意思是说 ISP不会不断更改此IP吗?
  4. 如果它是静态IP,Windows防火墙是否允许对端口9000进行ping操作?

您的生产服务器无法访问此IP /端口,这就是连接超时错误的原因。