WIZnet WIZ550io

Posted on
of 5
  • FYI, DNS seems to work within our LAN but it does not work outside of our LAN.

  • What happens when DHCP fails? does it output anything?

  • This seems to work ok for me .. with this code for example ..

    var eth = require("WIZnet").connect();
    var http = require("http");
    http.get("http://www.bbc.co.uk", function(res) {
     res.on('data', function(data) {

    So I get back the contents of whatever page I specify .. http://www.bbc.co.uk here

    Though it only works once unless I reboot in between .. executing the same code twice gives me a "ERROR: Socket error -7 while sending"

  • A bit more, if I just execute the http.get it works fine. Eventually I get an ERROR: No sockets found (or somesuch) [There is another thread on this - the sockets do close after a time and there is a limit of 8 (?) open at any one time ... so leaving a time gap between the gets would solve this] .. but once I get the error I then get a nasty bunch of this ..


    followed by the ESPRUINO disconnecting itself from the COM port.

    BUT for me, the extenal DNS resolution is working just fine :)

  • Pat

    OK, my understanding

    The timeout error happens because the WebIDE gets annoyed that Espruino is busy, and sends a ctrl-c, which breaks Espurino out of comms and causes the error. Ideally Gordon should give us a webide option to delay the ctrl-c

    The Wiznet subsystem (i.e. wiznet+espruino) has at least two known problems: the -7 error and the out of sockets error. The -7 error means "socket has wrong state" - internally we're trying to do something on a socket that is closed. I don't yet know why.

    Gordon has said that if you delay between GETS you don't run out of sockets, but I've not seen this - if I do repeated POSTS with a 2-minute delay I still run out after 8 POSTS.

    When I have time, I'm still digging into this - I've got Espruino building and I've added logging to the code, but I've not quite got to the point where it's telling me anything useful...


  • Thanks Martin,

    I am afraid my rocket scientist days are behind me .. happy to help test, but afraid I can offer little help in dealing with the guts of Espruino !


  • @mgg1010 - thanks for looking into this!

    The -7 error means "socket has wrong state" - internally we're trying to do something on a socket that is closed.

    Or it's possible that we're trying to 'open' a socket that is still open...

  • @Gordon, @Pat

    After a big of slogging, I think I may have fixed Wiznet. (OK, a bit optimistic, but it looks more reliable now in my testing :)

    I found three bugs

    1. The HTTP code was using srcport and dstport both with the same value, which I think caused GETs to fail when they overlapped.

    2. The DNS code wasn't releasing a socket, which caused "no free sockets" after 8 DNS queries.

    3. The socket code wasn't clearing the nonblock status, which caused odd things to happen if a socket was reused.

    I've submitted a pull request - hopefully Gordon can review and include these fixes in a future build - assuming I've not got anything wrong!


  • Hi Martin,

    Impressed :) Thanks ever so much .. look forward to having a crack at testing in due course !


  • I just pulled the changes in, and it's now been automatically built: http://www.espruino.com/binaries/git/com­mits/0d59179f1a98fb09b1d0c29945b40ae2014­2b759/

    Thanks again Martin - it's really appreciated :)

  • Things are definitely working better... but I am still having issues with http.get().

    I am attempting to do an http.get() to a Google Apps Content Service... this is what gets returned from the GET:

    <TITLE>Moved Permanently</TITLE>
    <H1>Moved Permanently</H1>
    The document has moved <A HREF="https://script.google.com/macros/s­/AKfycbwVqXlMKJ_g0OQtR4uyxuVLw

    I know the content service works because you can just copy and paste that url in any browser and it will log the data in my Google Spreadsheet as expected. Is it an issue with it being https?

    This is the link to the live Google Spreadsheet if anyone wants to play with it.


    The data gets logged in the "Data" sheet.

  • Yeah, HTTPS is not supported - if the link it's trying to go to is HTTPS, that's definitely the problem. I'd assume the espruino is ignoring the https, and sending a normal request to the same address - which responds with an attempt to redirect it to an https link.

    Neither Wiznet nor the CC3000 support HTTPS - (though rumor has it that both TI and Wiznet are planning to release a product in the future that does).
    Until such a device is released, you will need to do this using a service that doesn't require https/ssl.

  • Much better I think. My -7 error and out of sockets seem better/fixed, but I am still seeing

    [Fiddler] The socket connection to failed. 
    ErrorCode: 10061. 
    No connection could be made because the target machine actively refused it

    when I repeatedly click on the various buttons created by this code

    var eth = require("WIZnet").connect();
    /* eth.setIP({ ip : "" }); 
    eth.setIP({ dns : "" });
    eth.setIP({ gateway: "" });  */
    function onPageRequest(req, res) {
      res.writeHead(200, {'Content-Type': 'text/html'});
      res.write('<p>Button is '+(BTN.read()?'on':'off')+'</p>');
      res.write('<p>Turn LED1 <a href="/on1">on</a> or <a href="/off1">off</a></p>');
      res.write('<p>Turn LED2 <a href="/on2">on</a> or <a href="/off2">off</a></p>');
      res.write('<p>Turn LED3 <a href="/on3">on</a> or <a href="/off3">off</a></p>');
      res.write('<p>Turn all LEDs <a href="/onall">on</a> or <a href="/offall">off</a></p>');
      if (req.url=="/on1") digitalWrite(LED1, 1);
      if (req.url=="/off1") digitalWrite(LED1, 0);
      if (req.url=="/on2") digitalWrite(LED2, 1);
      if (req.url=="/off2") digitalWrite(LED2, 0);
      if (req.url=="/on3") digitalWrite(LED3, 1);
      if (req.url=="/off3") digitalWrite(LED3, 0);
      if (req.url =="/onall") {
      if (req.url =="/offall") {

    I am using a little chrome extension called iMacros to record a set of clicks on the page and then run in a loop.

  • Does it recover afterwards, or does it just die?

  • The Espruino console stays alive and responsive. Pings work all the time, even when the connection is refused.

    My macro runs continuously until I get the error (I cannot see any pattern as to which iteration it fails on - The macro is just hitting each of the 8 links on the page in sequence, over and over). When it eventually fails, issuing a eth.setIP() fixed it on the first 15 or so occasions (I did not count, but I can if helpful). After the 15th (or whatever it was) eth.setIP() does not revive it, but loading the whole script again does.

    The good news it that none of this is causing the Espruino to crash or drop the COM port.

  • Could it be that the macro is just hitting it too fast, and it can't keep up with it and is getting confused as a result of that?

  • Yes, possibly. I'll see if I can put some pauses in to slow it down.

    Having said that, before using the macro thing I was just doing it manually, and this too would eventually provoke the problem. But I was being nasty and clicking fast on links and/or refresh.

  • So, I put a 1 second delay after each hitting each link. Error apparent still. But after a variable number of iterations again :(

  • Hmm - I know I managed to cause problems by basically holding down F5 to refresh...

    I'm not sure quite why it happens - my guess is that somehow the socket loses the 'listen' state. I might be able to add something that'll check and then re-initialise it though.

  • Evidence of what is going on is tricky. I am not convinced it is (only) a timing problem. I put a 5 second delay after each link click and ran the macro .. it managed 31 complete iterations before returning the 10061 error. Next time, only 8 iterations.

    On the other hand, it could still be a timing issue. I don't think this test can properly point us in one direction or the other to be honest.

  • I've just committed some changes (b63a4f2970faaf853b43746515b6cbe46cb8cbb1­) that should sort out the server stability (at least they do for me).

    If you do requests very quickly, the W5500 will start rejecting them (as it is only handling one request at a time at the moment) - however you can now completely thrash it, and once you slow back down it'll stay working.

    Note: the WIZnet build isn't there yet - the build system broke recently. It should be up in an hour or two though.

  • Fantastic :) Am away from my playroom all day today, but will give it a shot tonight.

    Under light load, it all seems very stable now to me .. have been running all week without a blip.

  • Great! I think I fixed some outstanding CC3000 problems too - I've been running that for 48 hours without a problem as well (it still keeps needing resets, but Espruino does recover).

  • Excellent. Will have a crack at the CC3000 too then. That's where I started before the WIZ550io !

  • Well :) I have run my little macro script, with 1 seconds delays between all the clicks, and it has made it through 200 full iterations three times now without a single issue.

    I would say this is done ! Fantastic stuff. Having rock solid internet on Espruino is just great.

    On to the CC3000 ..

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

WIZnet WIZ550io

Posted by Avatar for Pat @Pat