Web component seems to work erraticaly. Error 1101

Hi there

I´ve been reading a lot of threads about Web component and the error 1101. The thing is, my app starts working properly but, in some moment (I use a clock to trigger grabbing o writting data into the server) it crashes with this error 1101.

I made a simple php script to mimic the tinyWebDB. I´m using two cell phones, and them both have the same issue. One of them is linked to Arduino by Bluetooth, and sends some sensor data to the other cell phone. This other cell phone can send some config data to the Arduino - attached one.

I appreciate some help, cause I´m running out of ideas. Thanks in advance. These are the main procedures and the "receiver phone" app. I don´t think is necessary to upload the "emitter phone app", that shows the same problem.

domoticaReceptorMiTinyWebDB.aia (54.8 KB)

this is the PHP script:

$tag = $_GET["Tag"];
$valor = $_GET["Valor"];
$accion = $_GET["Accion"];
//posibles valores son ObtenerRegistro, ListarTags, ListarBD, GrabarRegistro, EliminarRegistro

$separadorInicioTag = "#";
$separadorInicioValor = "~";


$archivoBD = "tinywebdb.dbf";

// *** PROCEDIMIENTO PARA GRABAR UN REGISTRO ***

if ($accion == "GrabarRegistro") 

{
    $volcado = file($archivoBD, FILE_SKIP_EMPTY_LINES);
    $localizacionLinea = (array_search($separadorInicioTag.$tag."\n", $volcado));
    if ($localizacionLinea === False) // NO ESTÁ LA TAG, AÑADO EL REGISTRO AL FINAL
    {
        $archivoAbierto = fopen($archivoBD, "a");
        fputs($archivoAbierto, $separadorInicioTag.$tag."\n");
        fputs($archivoAbierto, $separadorInicioValor.$valor."\n");
        fclose($archivoAbierto);
    }
    else // SÍ ESTÁ LA TAG, SUSTITUYO EL REGISTRO
    {
        $localizacionLinea++;
        while (substr($volcado[$localizacionLinea], 0, 1) <> $separadorInicioValor)
        {
            $localizacionLinea++; //BUSCO EL VALOR
        }
        $volcado[$localizacionLinea] = $separadorInicioValor.$valor."\n"; //SUSTITUYO EL VALOR
        $archivoAbierto = fopen($archivoBD, "w"); // Y GUARDO EL ARRAY MODIFICADO EN EL ARCHIVO
        for ($i = 0; $i < count($volcado); $i++)
        {
            if ((substr($volcado[$i], 0, 1) == $separadorInicioTag) or (substr($volcado[$i], 0, 1) == $separadorInicioValor))
                fputs($archivoAbierto, $volcado[$i]);
        }
        fclose($archivoAbierto);
    }

} //end if accio
// *** FIN DEL PROCEDIMIENTO PARA GRABAR UN  REGISTRO ***


if ($accion == "ObtenerRegistro")
{
    
    $volcado = file($archivoBD, FILE_SKIP_EMPTY_LINES);
    $localizacionTag = (array_search($separadorInicioTag.$tag."\n", $volcado));   
    if ($localizacionTag >= 0) // está la tag, y tengo su índice 
    {
        $localizacionValor = $localizacionTag;
        $localizacionValor++;
        while (substr($volcado[$localizacionValor], 0, 1) <> $separadorInicioValor)
        {
            $localizacionValor++; //BUSCO EL VALOR
        }
       // echo json_encode(array(trim($volcado[$localizacionTag], $separadorInicioTag."\n"),trim($volcado[$localizacionValor], $separadorInicioValor."\n")));
        echo json_encode(array(trim($volcado[$localizacionTag], "\n"),trim($volcado[$localizacionValor], "\n")));
    }
}

Test your web component and php without all the arduino/bluetooth stuff. does that work consistently?

Yeah, I tried and I have the same issue. Actually, I have another cell phone, independent from Arduino, that "speaks" with the Arduino attached one, and reports the 1101 error as well

as I said...

I mean, it only send receive data via web component with the other phone (tinywebdb like). I didn't say before. I explored the web option once I realized that tinywebdb sometimes cleans up the info. So now I'm trying out with a server and the web component.

All I am saying it test one thing at a time. Be sure that one thing (e.g. the web component) works OK and consistently, before adding further complexity.

I'm happy to answer myself. Once I removed the clock event, which triggered the save and grab info from the web event, everything works fine. Now, I have a much more effective app, triggering the web with a button instead the clock. I just use the clock to read a flag that indicates there have been changes in the database. Yeah, it is much more boring too.

My guess, too many requests provoke the nasty error 1101. I tried different intervals from 5000 to 15000, and all of them provoked the error. Now, working with a button, the error shows up when I click several times quickly.

1 Like