I'm actually having a lot of trouble reproducing this with your code. I uploaded it to the board and added the 'Access-Control-Allow-Origin': '*' header so I could access it from another file.
Then I stuck your polling code in a html file set to call 5 times a second. Any more and it refused to work:
But interspersed with the correctly returned page. After closing the extra windows the board immediately returned to working correctly. So I'd say the behaviour was perfect.
So I'm thinking this is probably the computer(s) that are requesting data that are still keeping connections open. Which web browser are you using on them?
and post the result? It's possible that connections are open and the HTTP header hasn't got through, so Espruino is just leaving sockets open waiting for a response. If so, it might be possible to add a timeout on Espruino's side that would close the connections if the header wasn't received within the first second.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
I'm actually having a lot of trouble reproducing this with your code. I uploaded it to the board and added the
'Access-Control-Allow-Origin': '*'
header so I could access it from another file.Then I stuck your polling code in a html file set to call 5 times a second. Any more and it refused to work:
And then loaded it in 4 windows - so that's 20 requests per second.
After a bit I started getting the following:
ERR Object {readyState: 0, status: 0, statusText: "abort"}
But interspersed with the correctly returned page. After closing the extra windows the board immediately returned to working correctly. So I'd say the behaviour was perfect.
So I'm thinking this is probably the computer(s) that are requesting data that are still keeping connections open. Which web browser are you using on them?
When you have problems, could you run:
and post the result? It's possible that connections are open and the HTTP header hasn't got through, so Espruino is just leaving sockets open waiting for a response. If so, it might be possible to add a timeout on Espruino's side that would close the connections if the header wasn't received within the first second.
You could also try:
That should force Espruino to close all server connections immediately.