B4R Question HttpJob Failed to connect with status 0 but connects in rHttpUtils2 example

hatzisn

Well-Known Member
Licensed User
Longtime User
Good evening everyone,

I try to connect to an https site from my program and I get "Failed to Connect" error message with status 0. The url of the HttpJob.Download is built with JSON sent to a WiFiServer object from the mobile phone. I copy the url from the logs and paste it to Chrome and works. I then paste it in the rHttpUtils2 example (https://www.b4x.com/android/forum/threads/module-rhttputils2-http-client.74785/#content)and works again. What might be wrong in my program (my program uses the B4X library) ?
 

hatzisn

Well-Known Member
Licensed User
Longtime User
Thanks for answering. There is no extra space or anything else illegal. I figured out though what is happening. Here is what is happening:

I am trying to create an ESP8266 configurator. To do this I firstly start the ESP8266 access point and I set its IP to 192.168.1.200 with this code:

Set IP of ESP8266 access point:
  void SetIP(B4R::Object* o) {
  //set-up the custom IP address
  IPAddress apIP(192, 168, 1, 200);
  WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));   // subnet FF FF FF 00
  }

I then create a WiFi server socket and send to the ESP8266 the connection to the WiFi details from a mobile phone.
The ESP8266 gets the details and connects to the WiFi and downloads some data from my server.
The problem is exactly the code above. If it runs it does not allow any outgoing connection and it returns
as a result Failed to Connect and status 0. When removed everything is working like a charm.
Why is this happening?

Edit - I suppose that I give to it wrong gateway because it keeps the configuration also afterwards when connected to the WiFi. Is it so?
Edit 2 - It is not so.
 
Last edited:
Upvote 0

hatzisn

Well-Known Member
Licensed User
Longtime User
Thanks, I have seen this in the past and have downloaded it to get some example code. What I need though is different because I want to pass also some other variables in the JSON I send and do it directly from any phone. I 've got it to work flawlessly now.
 
Upvote 0
Top