• function pageRequest(req, res) {
      res.writeHead(200);
      res.end("Hello World");
    }
    require("http").createServer(pageRequest­).listen(8080); // port 8080
    

    The code like this, when the borad work, it's ok for visiting the pages which the server supply at the very first time. But when I jump for the other websites and visit back via return history of browser, the server stop. I can't visit the server website again. I have to invoke load() for restart then I access the server again.

    How to Keep web server working for long time?

  • Tue 2020.09.22

    Hi, @user109783

    it sounds like this is what you are after:

    Espruino WebServer Module

    Other ideas:

    HTTP File Server
    WiFi Websocket Server

    http://www.espruino.com/Search?kw=server­



    Edit

    'How to Keep web server working for long time?'



    After a bit of digging, this page seems to be the origin of the snippet above:

    http://www.espruino.com/Internet

    As page requests are 'stateless' I now believe the initial post is after attempting to keep the connection alive indefinetly.

    Good overview,

    https://www.atlantic.net/vps-hosting/wha­t-is-stateless-stateful-models-web-devel­opment/

    Is this the task that is being attempted?

    or

    Is a very large char count page request being made and not all of the page content is returned?

  • The page I load is very simple and little cotent, I just press the F5 for refreshing the website, but somehow the server reject for connecting.

    And I invoked WIZnet.getStatus(), it was still working.

    {
      state: "online",
      id: "W5500",
      phylink: "up",
      phypowmode: "normal",
      by: 0, mode: 1, speed: 100, duplex: 0 }
    

    But when I visit website by http://ip , the browser reject like this: ERR_CONNECTION_REFUSED

  • When I first time visited the device like this, http://192.168.1.111
    Ok,no matter how I pressed the F5 button for refreshing, the connection was ok.
    But when I write a new website like: http://www.google.com and then press the back history for visiting the http://192.168.1.111 again, it failed, the browser rejected for visiting, maybe the device did.

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

How to keep a continuous web access while using require("http").createServer

Posted by Avatar for user109783 @user109783

Actions