PHP-数据导入到计数-超时错误

PHP-数据导入到计数-超时错误,php,mysql,curl,tally,Php,Mysql,Curl,Tally,我正在使用下面的代码将PHP连接到Tall。但当移动到生产时,它显示超时错误。但是,当我在本地计算机中运行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 Le

我正在使用下面的代码将PHP连接到Tall。但当移动到生产时,它显示超时错误。但是,当我在本地计算机中运行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);
        }


?>

  • -这是本地主机吗,例如127.0.0.1?如果 因此,您将无法从远程服务器访问它
  • 它看起来像一个局域网IP(例如192.168.0.104)。在这种情况下,它 可通过LAN(同一网络,另一台计算机)访问,但 不是来自远程服务器(不在同一局域网上)
  • 如果不是本地主机/LAN IP,它是静态IP吗?我的意思是,当地的 ISP不一直更改此IP
  • 如果是静态IP,Windows防火墙是否允许ping端口9000

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

    当您在本地主机上运行此代码时,它是否连接到同一IP地址?是的,它已连接