NAS Problem

sabatosabato Member Posts: 15
edited 2003-10-28 in Navision Attain
Hello,

well, I got some Problems with NAS. I try to connect from a PHP Site to the open Navision Socket.

This is the code on my php site:
<?php

$cfgServer    = "10.100.4.98";
$cfgPort    = 8085;
$cfgTimeOut    = 300;
$txt	= "Hello World";
$errno = 0;
$errstr = 0;

// open a socket
if(!$cfgTimeOut)
    // without timeout
    $usenet_handle = fsockopen($cfgServer, $cfgPort);
else
    // with timeout
    $usenet_handle = fsockopen($cfgServer, $cfgPort, &$errno, &$errstr, $cfgTimeOut);

if(!$usenet_handle) {
    echo "Connexion failed\n";
    exit();
}    
else {
    echo "Connected\n";
    $tmp = fgets($usenet_handle, 1024);
    //fputs($usenet_handle, "$txt");
    fclose ($usenet_handle);
}

?> 

And my Codeunit in Navision has the Following code:
OnRun()
IF ISCLEAR(CC2) THEN
    CREATE(CC2);
  IF ISCLEAR(SBA) THEN
    CREATE(SBA);
  CC2.AddBusAdapter(SBA, 0);

//Timeout setzten
SBA.ReceivingTimeout:= 20000;

  SBA.OpenSocket(8085, '');

CC2::MessageReceived(VAR InMessage : Automation "''.IDISPATCH")
//Nachricht abnehmen
InMsg:= InMessage;
//In einen InStream schreiben
InS:= InMsg.GetStream();
//Antwortnachricht erzeugen
OutMsg:= InMsg.CreateReply;
//In einen OutStream schreiben
OutS:= OutMsg.GetStream();
//Eingegangene Nachricht in die Ausgangsnachricht kopieren
COPYSTREAM(OutS,InS);
//Anwortnachricht versenden
OutMsg.Send(0);
InMsg.CommitMessage();

Now the first Problem is, I can connect to the Socket, but after that I get a Timeout:

Connected
Fatal error: Maximum execution time of 30 seconds exceeded in \inetpub\wwwroot\sma\fsocket.php on line 24


And the other thing is, how can I get the NAS to Reply the right answer and how can I e.g. enter data into the db throug a php site.

Hope some of you guys can help me. i don't know to much about NAS. Just startet it yesterday.

Comments

  • nicklaslnicklasl Member Posts: 10
    Answer to the first problem from php.net help:

    Your script can also be terminated by the built-in script timer. The default timeout is 30 seconds. It can be changed using the max_execution_time php.ini directive or the corresponding "php_value max_execution_time" Apache .conf directive as well as with the set_time_limit() function. When the timer expires the script will be aborted
  • sabatosabato Member Posts: 15
    Thanks for that, but I already figured that out =)

    Greetings
    sabato
Sign In or Register to comment.