0

I am tying to connect PHP to tally using follwing code. But it shows timeout error when moved to production. But succeeded in inserting data when i ran the code in tally in local machine Showing error Failed to connect to xxx.xxx.x.xx port 9000: Connection timed out something went wrong..... try later

<?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);
        }


?>
vignesh.D
  • 766
  • 4
  • 18

1 Answers1

1
  1. http://xxx.xxx.x.xxx:9000 - is this localhost, such as 127.0.0.1? If so, you won't be able to access it from a remote server.
  2. It looks like a LAN IP (e.g. 192.168.0.104). In which case, it will be accessible via the LAN (same network, another computer), but not from a remote server (which is not on the same LAN).
  3. If not a localhost/LAN IP, is it a static IP? By which I mean, the local ISP does not keep changing this IP?
  4. If it is a static IP, is port 9000 allowed to be pinged by the Windows firewall?

Your production server was not able to reach this IP/port, that's why the connection timeout error.

Mitalee Rao
  • 191
  • 6