Error: Not connected to the internet
when invoking http.createServer
#5608
Replies: 1 comment
-
Posted at 2016-11-02 by @gfwilliams I'm pretty sure the problem is that JavaScript executes asynchronously. Obviously I don't know what is in your startAP/enableWifiScan functions, but usually when you execute a command For instance for Espruino Wifi you need:
Also, which device are you using the Wifi on? Posted at 2016-11-02 by pthieu ESP8266 NodeMCU 1.0 (ESP-12E) Yes, the issue is the event-driven nature of JS. I was looking for a way to write simpler code since there isn't a reliable
Posted at 2016-11-02 by @gfwilliams There is a promise library, at least in later versions of Espruino. Moving this to the ESP8266 forum though - folks there might know what happens with Posted at 2016-11-07 by julian Gordon, pthieu, I seem to have a related problem. I am trying to get a web server running on boot up, I've used samples from the forums to test with. Here's the code I'm using: >dump()
As you can see, the code was saved(). I've also saved the wifi settings (which do work btw)! However, when booting I get: Loading 1836 bytes from flash... And, when I try to browse to port 8080 on the IP address of my ESP8266, the web browser can't load the page, however, if I type: >load() Voila, it starts working! I am assuming that the http server is starting before the wifi interface, thus producing the Not connected to the internet error and when I load the code manually after the ESP8266 has finished booting, it works. This isn't very handy! Any ideas chaps? Oh and pthieu, I think I have the same ESP8266 as you... Julian Posted at 2016-11-07 by pthieu @Julian: Yes, it will take some time for the network interface to establish a connection with the access point; the Change your code to this:
The doc for the Posted at 2016-11-07 by julian Hi pthieu, Wowzers, yes that works! The error has gone and the http server is running after a hard reboot. That link makes sense to me now, good find! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2016-11-02 by pthieu
Want to invoke http.createServer outside of connecting to a network or creating access point. But I get this error:
Error: Not connected to the internet
My code follows this logic in event loop:
i.e.
The reason for this is I want to be able to have the MCU serve a configuration page which will allow user to configure the network to connect to, making the device portable without hardcoding a network.
I could probably start the server after access point has been created, add a check to see if a server has been instantiated after connecting to a network, but wondering if there's an easier way.
Beta Was this translation helpful? Give feedback.
All reactions