HTTP server tutorial failed due to HTTP reset

Posted on
  • Dear Espruino community,

    Recently I have started using espruino and wanted to create a simple HTTP server based on the great tutorials provided here https://www.espruino.com/Internet#serverĀ­ .

    I am using espruino 1v99 built from source both on Raspberry Pi 3B and x86_64 architecture, but currently I am facing some issues with it.

    After creating the WEB server it starts up fine.

    var http = require("http");
    
    var i = 0;
    
    http.createServer(function (req, res) {
            i++;
      res.writeHead(200, {'Content-Type': 'text/plain'});
      res.write('Testing WEB server - ' + i + '\n')
      res.end()
    }).listen(8080);
    

    Initiating a request fails with RESET:

    1. Using the Browser, nothing is shown, only a Connection RESET error (ERR_CONNECTION_RESET)
    2. Using the curl, it returns with "Testing WEB server - 1" and "Testing WEB server - 2", BUT with an error code: curl: (56) Recv failure: Connection reset by peer. In my understanding code56 means some serious connection issue
    3. using wget the response is returned, but also with an error: "Read error at byte 23 (Connection reset by peer).Retrying."

    Can someone help me out? I want to build a RESTful interface using HTTP.

    Any help is highly appreciated!

  • Thanks - I'll look into this. It seems to be an issue with the current master branch build.

    Can you git checkout RELEASE_1V99, then make clean and make and it should work for you (I just tested).

  • Ok, I just tracked this down to a PR that was designed to help with testing :/ The latest version should be fixed now.

  • Works fine, thank you for your quick help!

  • Now if I quit espruino and restart it, sockets seems to be remained opened in "TIME_WAIT" state, so the new instance is not able to bind to the port.

    This happens both in the latest master branch, and in the the RELEASE_1V99. by the time the "RESET" bug was implemented, this does not happened due to the socket reset. Do you have any information, that is this still a linux-related issue (should I set some tcp reuse flag)? (Currently my tcp_tw_reuse flag was set to 1, but it did not solved my problem)

  • Try a build now - hopefully it'll be a bit better.

  • Thank you Gordon, it is MUCH better.

  • To be fair that change wasn't mine but @opichals :) Glad it's working for you now!

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

HTTP server tutorial failed due to HTTP reset

Posted by Avatar for gabika6 @gabika6

Actions