MDBT42 http module using sim808

Posted on
  • Hello,

    I'm using MDBT42 flashed with the latest firmware (2v08) and I'm experiencing a strange behavior with http module.
    After everything initialized using require('SIM900') I got ~1300 free memory and then I started getting \posting data from\to a server every 30 seconds and after the first successful response and starting from the second request I'm getting this error but I'm still getting successful responses...

    Uncaught Error: 0, CLOSED already registered
     at line 1 col 44
    if(m[a])throw Error(a+" already registered");m[a]=d
                                               ^
    in function "registerLine" called from line 2 col 432
    ...;g[a]=void 0;l=!1;return""});else return g[a]=void 0,""
                                  ^
    in function "c" called from line 1 col 25
    e=void 0;var u;c&&(u=c(t))?(e=k,c=u):clearTimeout(h);­void 0=...
                            ^
    in function "e" called from line 2 col 16
    k=!0);k||e&&e(h)}b=b.substr(a+1);if(k&&f­)return d("");"\n"==...
                   ^
    in function called from system
    

    ... while the free memory decrease every request.

    FREE MEMORY - 851
    FREE MEMORY - 724
    FREE MEMORY - 713
    ...
    ...
    FREE MEMORY - 173
    FREE MEMORY - 165
    FREE MEMORY - 158
    FREE MEMORY - 149
    FREE MEMORY - 146
    FREE MEMORY - 143
    FREE MEMORY - 138
    FREE MEMORY - 134
    

    After a couple of minutes I got those errors:

    ERROR: Error processing Serial data handler - removing it.
    Execution Interrupted during event processing.
    New interpreter error: CALLBACK,MEMORY
    New interpreter error: BUFFER_FULL
    [
      "BUFFER_FULL",
      "CALLBACK",
      "LOW_MEMORY",
      "MEMORY"
     ]
    

    The issue is the same using GET and POST.

    Am I doing it wrong?
    Is there any better way to do this interval thing?

    Here is the full code for my trials.

    Thank you.

    let sim={};
    let m;
    
    function onInit(){
      E.setConsole("Bluetooth");
    
      setTimeout(() => {
        Serial1.setup(115200,{rx:D8,tx:D6});
      }, 1*1000);
    }
    
    function initGPRS(){
      setTimeout(()=>{
        sim.gprs = require('SIM900').connect(Serial1, null, (err)=>{
          if (err) throw err;
          cntGPRS((ip)=>{
            console.log(ip);
            console.log("Error Flags", E.getErrorFlags());
            m = process.memory().free;
            console.log("==========\r\nFREE MEMORY BEFORE STARTING REQUESTS:", m, "\r\n==========\r\n");
            setInterval(()=>{
              testGet1();
              //testGet2();
              //testPost();
            }, 30*1000);
          });
        });
      }, 5*1000);
    }
    
    function cntGPRS(cb){
      setTimeout(()=>{
        sim.gprs.connect('', '', '', (err)=>{
          if (err) throw err;
          setTimeout(()=>{
            sim.gprs.getIP((err, ip)=>{
              if (err) throw err;
              if (cb) cb(ip);
            });
          }, 5*1000);
        });
      }, 5*1000);
    }
    
    function testGet1(){
      if(!sim.http){
        sim.http = require("http");
      }
      try{
        sim.http.get('http://www.pur3.co.uk', (res)=> {
          let content = "";
          res.on('data', (d)=> {
            content+=d;
          });
          res.on('close', ()=>{
            //console.log(content);
            console.log("Got Response with statuscode:", res.statusCode);
            console.log("Error Flags", E.getErrorFlags());
            m = process.memory().free;
            console.log("==========\r\nFREE MEMORY - GET1", m, "\r\n==========\r\n");
          });
        }).on('error', (e)=>{
          console.log("ERROR:", e);
          console.log("After ERROR GET", m);
        });
      }catch(e){
        console.log("ERROR http.get:", e);
      }
    }
    
    function testGet2(){
      require("http").request({
        "host":"http://www.pur3.co.uk",
        "path":"/",
        "method":"GET",
      }, (res)=> {
        let content = "";
        res.on('data', (d)=>{ content+=d;});
        res.on('close', (d)=>{
          //console.log(content);
          console.log("Got Response with statuscode:", res.statusCode);
          console.log("Error Flags", E.getErrorFlags());
          m = process.memory().free;
          console.log("==========\r\nFREE MEMORY - GET2", m, "\r\n==========\r\n");
        });
      }).end();
    }
    
    function testPost(){
      postJSON({postURL:"http://www.pur3.co.uk­", data: {d:7}, callback: (d)=>{
        if(d) console.log("Response:", d);
        console.log("Error Flags", E.getErrorFlags());
        m = process.memory().free;
        console.log("==========\r\nFREE MEMORY - POST", m, "\r\n==========\r\n");
      }});
    }
    
    function postJSON(params) {
      if(!sim.http){
        sim.http = require("http");
      }
      try{
        setTimeout(()=>{
          content = JSON.stringify(params.data);
          let options = url.parse(params.postURL);
          options.method = 'POST';
          options.headers = {
            "Content-Type":"application/json",
            "Content-Length":content.length
          };
          let req = sim.http.request(options, (res)=>{
            let content = "";
            res.on('data', (d)=>{ content+=d; });
            res.on('close', (d)=>{
              console.log("Got Response with statuscode:", res.statusCode);
              params.callback();
            });
          });
          req.on('error', (e)=>{ params.callback(e);});
          req.end(content);
        }, 5*1000);
      }catch(e){
        console.log(e);
      }
    }
    
  • Hi! What you're doing looks fine - although I'm not sure the console log you posted actually matches the code that you posted up?

    Are you sure you're not calling initGPRS more than once? I don't see it called at all in the code, but if it were called multiple times it would definitely cause a memory leak.

    Looking at the module the Uncaught Error: 0, CLOSED already registered message would seem to be caused by the module not actually sending the line 0, CLOSED when the request finishes. I don't know if that's some difference between the SIM808 and SIM900 or not, but it might be I need to make a few tweaks to the module to get it to handle that properly.

    Please could you run sim.gprs.at.debug(), make a request, then post what gets printed up here?

    Hopefully it'll allow me to make some changes to the module to fix the issue.

  • Hi Gordon,

    although I'm not sure the console log you posted actually matches the code that you posted up?

    Yes I Just clean it up to be easier to see the important data.

    Are you sure you're not calling initGPRS more than once? I don't see it called at all in the code, but if it were called multiple times it would definitely cause a memory leak.

    I am calling it only once manually from the left side of the IDE when the SIM808 is ready - Just for testing.

    AT Debug:

    >sim.gprs.at.debug()
    ={
      line: "",
      lineCallback: undefined,
      handlers: {
        "+RECEIVE": function (b) { ... },
        "+D": function (b) { ... }
       },
      lineHandlers: {  },
      waiting: [  ],
      dataCount: 0 }
    

    First request:

    >testGet1()
    ["AT+CIPSTART=0,\"TCP\",\"http://www.pur­3.co.uk\",80\r\n"
    =undefined
    ] "\r\nOK\r\n"
    ] "\r\n0, CONNECT OK\r\n"
    ] "\r\n> "
    ] "\r\n0, SEND "
    ] "OK\r\n"
    ] "\r\n+RECEIVE,0,134"
    ] "8:\r\nHTTP/1.1 200 OK\r\nDate: Thu, 31 Dec 2020 11:09:20 GMT\r\nServer: Apache/2.4.18 (Ubuntu)\r\nVary: Accept-Encoding\r\nConnection: close\r\nContent-Type: text/html;charset=UT"
    ] "\r\n+RECEI"
    ] "VE,0,1348:\r\n/h1> \r\n<!--\t\t<form method=\"get\" class=\"searchform\" action=\"search.php\">\r\n\t\t\t<div><in­put type=\"text\" name=\"text\" class=\"textbox\" />"
    ] "\r\n+RECEIVE,"
    ] "0,1325:\r\na wide variety of platforms. For more information, please see the <a href=\"About\"><span>About</span></a> page.<br />\n<br />\n<strong>We also develop the&nbs"
    ["AT+CIPCLOSE=0,1\r\n"
    Got Response with statuscode: 200
    Error Flags [  ]
    ==========
    FREE MEMORY - GET1 885
    ==========
    ] "\r\n0, CLOSE OK\r\n"
    

    Second request:

    >testGet1()
    ["AT+CIPSTART=0,\"TCP\",\"http://www.pur­3.co.uk\",80\r\n"
    =undefined
    ] "\r\nOK\r\n"
    Uncaught Error: 0, CLOSED already registered
     at line 1 col 44
    if(m[a])throw Error(a+" already registered");m[a]=d
                                               ^
    in function "registerLine" called from line 2 col 432
    ...;g[a]=void 0;l=!1;return""});else return g[a]=void 0,""
                                  ^
    in function "c" called from line 1 col 25
    e=void 0;var u;c&&(u=c(t))?(e=k,c=u):clearTimeout(h);­void 0=...
                            ^
    in function "e" called from line 2 col 16
    k=!0);k||e&&e(h)}b=b.substr(a+1);if(k&&f­)return d("");"\n"==...
                   ^
    in function called from system
    ] "\r\n0, CONNECT OK\r\n"
    ] "\r\n> "
    ] "\r\n0, SEND"
    ] " OK\r\n"
    ] "\r\n+RECEIVE,0,134"
    ] "8:\r\nHTTP/1.1 200 OK\r\nDate: Thu, 31 Dec 2020 11:09:43 GMT\r\nServer: Apache/2.4.18 (Ubuntu)\r\nVary: Accept-Encoding\r\nConnection: close\r\nContent-Type: text/html;charset=U"
    ] "\r\n+RECEI"
    ] "VE,0,1348:\r\n/h1> \r\n<!--\t\t<form method=\"get\" class=\"searchform\" action=\"search.php\">\r\n\t\t\t<div><in­put type=\"text\" name=\"text\" class=\"textbox\" />\r\n"
    ] "\r\n+RECEIVE"
    ] ",0,1325:\r\na wide variety of platforms. For more information, please see the <a href=\"About\"><span>About</span></a> page.<br />\n<br />\n<strong>We also develop the&nbs"
    ["AT+CIPCLOSE=0,1\r\n"
    Got Response with statuscode: 200
    Error Flags [  ]
    ==========
    FREE MEMORY - GET1 750
    ==========
    ] "\r\n0, CLOSE OK\r\n"
    

    Thank you,

  • Great - thanks! I'll look into this - it seems that your module reports 0, CLOSE and not 0, CLOSED - so it may be a reasonably simple fix

  • Hi - please can you try re-uploading your code and see if that fixes it? I just updated the SIM900 module

  • Hi, thank you Gordon,

    Now I'm getting this error:

    ["AT+CIPSTART=1,\"TCP\",\"http://www.pur­3.co.uk\",80\r\n"
    ] "\r\nOK\r\n"
    Uncaught Error: 1, CLOSE already registered
     at line 1 col 44
    if(m[a])throw Error(a+" already registered");m[a]=d
                                               ^
    in function "registerLine" called from line 2 col 429
    ...;g[a]=void 0;l=!1;return""});else return g[a]=void 0,""
                                  ^
    in function "c" called from line 1 col 25
    e=void 0;var u;c&&(u=c(t))?(e=k,c=u):clearTimeout(h);­void 0=...
                            ^
    in function "e" called from line 2 col 16
    k=!0);k||e&&e(h)}b=b.substr(a+1);if(k&&f­)return d("");"\n"==...
                   ^
    in function called from system
    ] "\r\n1, CONNEC"
    ] "T OK\r\n"
    ] "\r\n> "
    ] "\r\n1"
    ] ", SEND OK\r\n"
    ] "\r\n+RECEIVE,1,1348:\r\nHTT"
    ] "\r\n+RECEIVE,1"
    ] ",1348:\r\n/h1> \r\n<!--\t\t<form method=\"get\" class=\"searchform\" action=\"search.php\">\r\n\t\t\t<div><in­put type=\"text\" name=\"text\" class=\"textbox\" />\r\n  \t\t\t<input type=\"submit\" name=\"search\" cla"
    ] "\r\n+"
    ] "RECEIVE,1,1325:\r\na wide variety of platforms. For more information, please see the <a href=\"About\"><span>About</span></a> page.<br />\n<br />\n<strong>We also de"
    ["AT+CIPCLOSE=1,1\r\n"
    Got Response with statuscode: 200
    Error Flags [  ]
    ==========
    FREE MEMORY - GET1 148
    ==========
    ] "\r\n1, CLOSE OK\r\n"
    > 
    
  • Ok - was there anything that came before that?

    Please can you try changing your require("SIM900") to require("https://raw.githubusercontent.c­om/espruino/EspruinoDocs/sim808/devices/­SIM900.js")?

    I made some other tweaks that would fix this I think but I don't want to push them fully live until you've tested them :)

  • Testing...

  • @Gordon thank you very much!
    It's doing GET/POST requests for ~13 hours now without any errors or memory leak :)

  • Great! I'll merge that in :)

  • Until ... :)

    It's definitely a lot better but I did some more tests, I shut down the remote service while continuing the POST requests to it (every 30 seconds), I got a 'no response' message as expected but it seems to be a memory leak here.
    BTW, 1 is when the service is up and running...

    Loading 12442 bytes from flash...
    Running onInit()...
    >initGPRS()
    =undefined
    ==========
    FREE MEMORY BEFORE STARTING REQUESTS: 928
    ==========
    Response: 1
    ==========
    FREE MEMORY - POST 664
    ==========
    Response: 1
    ==========
    FREE MEMORY - POST 664
    ==========
    Response: 1
    ==========
    FREE MEMORY - POST 664
    ==========
    Response: 1
    ==========
    FREE MEMORY - POST 664
    ==========
    ERROR: { "code": -15,
      "message": "no response"
     }
    ==========
    FREE MEMORY - ERROR POST 563
    ==========
    ERROR: { "code": -15,
      "message": "no response"
     }
    ==========
    FREE MEMORY - ERROR POST 473
    ==========
    New interpreter error: LOW_MEMORY,MEMORY
    ERROR: { "code": -15,
      "message": "no response"
     }
    ==========
    FREE MEMORY - ERROR POST 152
    ==========
    ERROR: { "code": -15,
      "message": "no response"
     }
    ==========
    FREE MEMORY - ERROR POST 430
    ==========
    ERROR: { "code": -15,
      "message": "no response"
     }
    ==========
    FREE MEMORY - ERROR POST 434
    ==========
    ERROR: Error processing Serial data handler - removing it.
    Execution Interrupted during event processing.
    New interpreter error: CALLBACK
    ERROR: { "code": -15,
      "message": "no response"
     }
    ==========
    FREE MEMORY - ERROR POST 136
    ==========
    ERROR: Ctrl-C while processing interval - removing it.
    Execution Interrupted during event processing.
    > 
    

    With Debug (Service down all time):

    Loading 12442 bytes from flash...
    Running onInit()...
    >initGPRS()
    =undefined
    ==========
    FREE MEMORY BEFORE STARTING REQUESTS: 927
    ==========
    >sim.gprs.at.debug()
    ={
      line: "",
      lineCallback: undefined,
      handlers: {
        "+RECEIVE": function (b) { ... },
        "+D": function (b) { ... }
       },
      lineHandlers: {
        "0, CLOSE": function (b) { ... },
        "1, CLOSE": function (b) { ... },
        "2, CLOSE": function (b) { ... },
        "3, CLOSE": function (b) { ... },
        "4, CLOSE": function (b) { ... }
       },
      waiting: [  ],
      dataCount: 0 }
    ["AT+CIPSTART=0,\"TCP\",\"fake.server.co­m\",80\r\n"
    ] "\r\nOK\r\n"
    ["AT+CIPSTART=1,\"TCP\",\"fake.server.co­m\",80\r\n"
    ] "\r\nOK\r\n"
    ["AT+CIPSTART=2,\"TCP\",\"fake.server.co­m\",80\r\n"
    New interpreter error: LOW_MEMORY,MEMORY
    ] "\r\nOK\r\n"
    ] "\r\n0, CONNECT FAIL\r\n"
    ERROR: { "code": -15,
      "message": "no response"
     }
    ==========
    FREE MEMORY - ERROR POST 152
    ==========
    ERROR: { "code": -15,
      "message": "no response"
     }
    ==========
    FREE MEMORY - ERROR POST 430
    ==========
    ["AT+CIPSTART=0,\"TCP\",\"fake.server.co­m\",80\r\n"
    ] "\r\nOK\r\n"
    ] "\r\n1, CONNECT FAIL\r\n"
    ERROR: { "code": -15,
      "message": "no response"
     }
    ==========
    FREE MEMORY - ERROR POST 434
    ==========
    ["AT+CIPSTART=1,\"TCP\",\"fake.server.co­m\",80\r\n"
    ] "\r\nOK\r\n"
    ] "\r\n2, CONNECT FAIL\r\n"
    ["AT+CIPSTART=2,\"TCP\",\"fake.server.co­m\",80\r\n"
    ] "\r\nOK\r\n"
    ERROR: Error processing Serial data handler - removing it.
    Execution Interrupted during event processing.
    New interpreter error: CALLBACK
    ERROR: { "code": -15,
      "message": "no response"
     }
    ==========
    FREE MEMORY - ERROR POST 136
    ==========
    ["AT+CIPSTART=2,\"TCP\",\"fake.server.co­m\",80\r\n"
    ERROR: Ctrl-C while processing interval - removing it.
    Execution Interrupted during event processing.
    > 
    
  • Strange... However from the dump it looks a lot like the SIM808 is trying to connect for a while before it gives up? Maybe there's a 60 second connection timeout internally?

    So what's happening is you're trying to post every 30 seconds, so you're queueing up multiple requests before the last ones have finished.

    What happens if you just stop making more HTTP requests (maybe with testGet1 = function(){}) then wait 5 minutes and see how much memory is used?

  • The default timeout seems to be 120 seconds? from simcom.
    https://simcom.ee/documents/SIM808/SIM80­0%20Series_AT%20Command%20Manual_V1.09.p­df

    Anyway,
    GET requests testGet1 = function() {} worked fine every 30 seconds even when the service was down.
    POST requests in other hand, I tried requests every 130 seconds for more than 10 hours when the service was up. I started with 666 free memory and finished with 451. This leak occurred only once, from 666 to 451 with "no response" message.
    There were more "no response" messages but the leak occurred only on one of them.

    I will do the same test with POST requests, service down, 5 minutes interval and see if still there any memory leak.

    Is there a way to specify a 30 seconds timeout in the GET/POST requests from http module?

    Thank you.

  • Is there a way to specify a 30 seconds timeout in the GET/POST requests from http module?

    There's no timeout built in to Espruino itself I'm afraid, but you may well be able to issue an AT command to the SIM808 that will configure the timeout?

    Worst case it might be possible to do a bit of a hack to force the closure of the socket after a timeout, but hopefully it won't come to that.

  • I think it's ok.
    I'll see how it goes in the long term.
    Thank you Gordon.

  • Hello again,
    Still testing this module https://raw.githubusercontent.com/esprui­no/EspruinoDocs/sim808/devices/SIM900.js­

    I don't know if this related to the request timeout but I'm posting data every 10 minutes, at first this works ok, but when I got {"code":-15,"message":"no response"} response so after 10 minutes, the next request will begin with this error message.

    Uncaught Error: 0, CONNECT OK already registered
     at line 1 col 44
    if(h[a])throw Error(a+" already registered");h[a]=b
                                               ^
    in function "registerLine" called from line 1 col 174
    ...CONNECT FAIL'),socks[a]=!0}),at.registerLine(a+'­, CONNECT FA...
                                  ^
    in function "c" called from line 1 col 25
    g=void 0;var b;c&&(b=c(a))?(g=e,c=b):clearTimeout(d);­void 0=...
                            ^
    in function "g" called from line 2 col 4
    g(f)}b=b.substr(a+1);if(p&&d)return q("");"\n"==b[0]&&(b=b.s...
       ^
    in function called from system
    

    It might work, but over time after couple requests this getting worse and the majority of the responses are 'no response' with the error above.

    What I'm trying to establish for now is to find the best way for stable connection and requests so I can continue my project knowing I have reliable way dealing with this.

    All test I did are when there is a good cellular signal.

    I tried those 2 scenarios with same results:
    1:

    • gprs = require('https://.../devices/SIM900.js')­.connect(Serial1... - ONCE
    • gprs.connect('', '', '', (err)... - ONCE
    • gprs.getIP((err, ip) - ONCE
    • require("http").request(options, (res) - EVERY 10 MINUTES

    2:

    • gprs = require('https://.../devices/SIM900.js')­.connect(Serial1... - ONCE
    • gprs.connect('', '', '', (err)... - EVERY 10 MINUTES
    • gprs.getIP((err, ip) - EVERY 10 MINUTES
    • require("http").request(options, (res) - EVERY 10 MINUTES
    • "AT+CIPSHUT" command (deactivate gprs) - EVERY 10 MINUTES

    Your help is greatly appreciated..
    Michael.

  • Can you try now and see if it's any better please?

  • Hi,

    I'm still getting the error, this is how it looks using the second scenario when at.debug enabled

    ["AT+CSTT=\"apn.net\", \"\", \"\"\r\n"
    ] "\r\nO"
    ] "K\r\n"
    ["AT+CIICR\r\n"
    ] "\r\nOK"
    ] "\r\n"
    ["AT+CIFSR\r\n"
    ] "\r\n"
    ] "ip.ip.ip.ip\r\n"
    ["AT+CIPSTART=0,\"TCP\",\"fake.server.co­m\",80\r\n"
    ] "\r\nOK\r\n"
    ] "\r\n0, CONNECT O\r\n"
    ] "\r\n0, CLOSED\r\n"
    ERROR: {"code":-15,"message":"no response"}
    ] "\r\nS"
    ] "HUT OK\r\n"
    

    And then after 10 minutes

    ["AT+CSTT=\"apn.net\", \"\", \"\"\r\n"
    ] "\r\nOK"
    ] "\r\n"
    ["AT+CIICR\r\n"
    ] "\r\nO"
    ] "K\r\n"
    ["AT+CIFSR\r\n"
    ] "\r\n"
    ] "ip.ip.ip.ip\r\n"
    ["AT+CIPSTART=0,\"TCP\",\"fake.server.co­m\",80\r\n"
    ] "\r\nOK\r\n"
    Uncaught Error: 0, CONNECT OK already registered
     at line 1 col 44
    if(h[a])throw Error(a+" already registered");h[a]=b
                                               ^
    in function "registerLine" called from line 1 col 174
    ...CONNECT FAIL'),socks[a]=!0}),at.registerLine(a+'­, CONNECT FA...
                                  ^
    in function "c" called from line 1 col 25
    g=void 0;var b;c&&(b=c(a))?(g=e,c=b):clearTimeout(d);­void 0=...
                            ^
    in function "g" called from line 2 col 4
    g(f)}b=b.substr(a+1);if(p&&d)return q("");"\n"==b[0]&&(b=b.s...
       ^
    in function called from system
    ] "\r\n0, CONNEC"
    ] "T OK\r\n"
    ] "\r\n> "
    ] "\r\n0, SE"
    ] "ND OK\r\n\r\n+RECEIVE,0,159:\r\nHTTP/1.1 200 OK\r\nConnection: close\r\nDate: Mon, 18 Jan 2021 15:47:55 GMT\r\nContent-Type: application/json; charset="
    ["AT+CIPCLOSE=0,1\r\n"
    ] "\r\n0, CLOSE OK\r\n"
    ["AT+CIPSTART=0,\"TCP\",\"fake.server.co­m\",80\r\n"
    ] "\r\nOK\r\n"
    ] "\r\n0,"
    ] " CONNECT OK\r\n"
    ] "\r\n> "
    ] "\r\n0, SEN"
    ] "D OK\r\n\r\n+RECEIVE,0,159:\r\nHTTP/1.1 200 OK\r\nConnection: close\r\nDate: Mon, 18 Jan 2021 15:48:08 GMT\r\nContent-Type: application/json; charset=u"
    ["AT+CIPCLOSEE=0,1\r\n"
    ] "\r\n0, CLOSE OK\r\n"
    ] "\r\n"
    ] "SHUT OK\r\n"
    

    Thank you

  • Ahh, sorry - this time I updated the master branch, not sim808 and didn't spot the different link. Please can you try require("https://raw.githubusercontent.c­om/espruino/EspruinoDocs/master/devices/­SIM900.js")

  • Thank you @Gordon! It's better now.

    There is a similar bug with Uncaught Error: 0, SEND OK already registered

    Here is 2 examples..

    Example 1:

    ["AT+CIPSTART=0,\"TCP\",\"fake.server.co­m\",80\r\n"
    ] "\r\nOK\r\n"
    ] "\r\n0, CONNECT OK\n"
    ] "\r\n0, CLOED\r\n"
    ] "\r\nERROR\r\n"
    

    then every 10 minutes

    ["AT+CIPSTART=1,\"TCP\",\"fake.server.co­m\",80\r\n"
    ] "\r\nOK\r\n"
    ] "\r\n1, CONNECT OK\r\n"
    ] "\r\n1, CLOSED\r\n"
    ERROR: {"code":-15,"message":"no response"}
    Uncaught Error: 0, SEND OK already registered
     at line 1 col 44
    if(h[a])throw Error(a+" already registered");h[a]=b
                                               ^
    in function "registerLine" called from line 1 col 254
    ...+', SEND FAIL'),busy=!1,''}),at.registerLine(a+',­ SEND FAIL'...
                                  ^
    in function called from system
    

    when the sockets debug look like this

    {
      "socks": [ true ],
      "sockData": [
        "",
        "",
        "",
        "",
        "",
        "0124": "undefined"
       ]
     }
    

    Example 2:

    ["AT+CIPSTART=0,\"TCP\",\"fake.server.co­m\",80\r\n"
    ] "\r\nOK\r\n"
    ] "\r\n0, CONNECT OK\r\n"
    ] "\r\n> "
    ] "\r\n0, END OK\r\n"
    ] "\r\n+RE"
    ] "CEIVE,0,124:\r\nHTTP/1.1 408 Request Timeout\r\nConnection: close\r\nDate: Thu, 21 Jan 2021 14:32:35 GMT\r\nContent-Length: 0\r\n\r\n"
    ] "\r\n, CLOSED\r"
    ] "\n"
    

    then every 10 minutes

    ["AT+CIPSTART=1,\"TCP\",\"fake.server.co­m\",80\r\n"
    ] "\r\nOK\r\n"
    ] "\r\n1, CONNECT OK\r\n"
    ] "\r\n1, CLOSED\r\n"
    ERROR: {"code":-15,"message":"no response"}
    Uncaught Error: 0, SEND OK already registered
     at line 1 col 44
    if(h[a])throw Error(a+" already registered");h[a]=b
                                               ^
    in function "registerLine" called from line 1 col 254
    ...+', SEND FAIL'),busy=!1,''}),at.registerLine(a+',­ SEND FAIL'...
                                  ^
    in function called from system
    

    when the sockets debug look like this

    {
      "socks": [ true, undefined ],
      "sockData": [
        "",
        "",
        "",
        "",
        ""
       ]
     }
    

    Thanks again.

  • Are you sure you have a good connection from the SIM808 to the board (including ground?). It's looking like the reason things are going wrong is data is getting lost. For example 0, CLOED should be 0, CLOSED and for your last one you get , CLOSED without a socket number.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

MDBT42 http module using sim808

Posted by Avatar for michael_101 @michael_101

Actions