Hello - I was checking out the httputils2 module for an existing project that also utilizes ESP8266WiFi and WiFiServerSocket. Basically I have my socket server configured in prefix mode and I wanted to add some functionality where my esp8266 on startup after connected to my access point makes a simple GET request with some query parameters passed on URL, something like:
http://10.0.0.200/device?myipaddr=10.0.0.30
I tested the httputils2 out in a test project and it works great. However when mixed in with my current project which has the wifi server - it didn't work as expected. It never seemed to connect to the client, however if I initiated a connection *to* my device on the WIFI server, suddenly the original outgoing http request flushes out - the web server on the other ends see the connection (and incidentally I also received the inbound socket server request and processed just fine).
Ultimately I think there are several issues, one my existing program has quite a global object and byte arrays and using other libraries like the EEPROM library. I think incorporating the httputils2 which defines a ResponseCache byte array of 5K "tipped it over the edge" and I was hitting stack issues (yes I had increased the stack considerably) (note to anyone else who might experience this similar problem - reducing this array size helped - I reduced mine to 500).
Second issue, which is really the premise of the post is the httputils2 also uses asyncstreams and the default calls backs are:
My wifi server call backs also used the same names "Astream_NewData", "Astream_Error" but in a totally different module. I think that there was some ambiguity/conflict between the httputils2 module subs and my own modules call back subs (all with same names). My originally thinking was that the object using those subs as call backs used the subs with the same name in the module that it was contained in (astream object in the code above and the call backs are all in the same module).
So the question is what is the scope of the call back subs/names? If I'm not trying to use same sub for event firings of different objects, I assume the right thing to do is just use different call back names (i.e. "Astream_NewData2", "Astream_Error2").
Note, doing the above in addition to reducing the size of ResponseCache in httputils2 solved my issue and I've got a server and client working in the same project.
Posting this as it might help someone else as well and get some clarity for myself
http://10.0.0.200/device?myipaddr=10.0.0.30
I tested the httputils2 out in a test project and it works great. However when mixed in with my current project which has the wifi server - it didn't work as expected. It never seemed to connect to the client, however if I initiated a connection *to* my device on the WIFI server, suddenly the original outgoing http request flushes out - the web server on the other ends see the connection (and incidentally I also received the inbound socket server request and processed just fine).
Ultimately I think there are several issues, one my existing program has quite a global object and byte arrays and using other libraries like the EEPROM library. I think incorporating the httputils2 which defines a ResponseCache byte array of 5K "tipped it over the edge" and I was hitting stack issues (yes I had increased the stack considerably) (note to anyone else who might experience this similar problem - reducing this array size helped - I reduced mine to 500).
Second issue, which is really the premise of the post is the httputils2 also uses asyncstreams and the default calls backs are:
B4X:
astream.Initialize(st, "Astream_NewData", "Astream_Error")
My wifi server call backs also used the same names "Astream_NewData", "Astream_Error" but in a totally different module. I think that there was some ambiguity/conflict between the httputils2 module subs and my own modules call back subs (all with same names). My originally thinking was that the object using those subs as call backs used the subs with the same name in the module that it was contained in (astream object in the code above and the call backs are all in the same module).
So the question is what is the scope of the call back subs/names? If I'm not trying to use same sub for event firings of different objects, I assume the right thing to do is just use different call back names (i.e. "Astream_NewData2", "Astream_Error2").
Note, doing the above in addition to reducing the size of ResponseCache in httputils2 solved my issue and I've got a server and client working in the same project.
Posting this as it might help someone else as well and get some clarity for myself
Last edited: