Skip to content

WifiClient.available() fails with errno 88 #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
randomswdev opened this issue Dec 8, 2016 · 38 comments
Closed

WifiClient.available() fails with errno 88 #85

randomswdev opened this issue Dec 8, 2016 · 38 comments

Comments

@randomswdev
Copy link

I'm trying to connect to an MQTT broker via WiFi. I'm able to execute the connection (I see it logged on the server), but when my client tries to read the answer from the server it fails, with the following line:

[E][WiFiClient.cpp:201] available(): 88

(the line number is different than the one in the current source code, because of some additional traces I added).

If I understand correctly, errno 88 means NOTIMPLEMENTED.

@me-no-dev
Copy link
Member

Are you using it through Arduino IDE or through IDF as component?

@randomswdev
Copy link
Author

randomswdev commented Dec 8, 2016

Through the Arduino IDE. I just fetched the latest esp32-arduino, and the issue is still present.

@me-no-dev
Copy link
Member

Maybe regression in IDF... I'll have a look. I'm working on new faster client anyway :)

@randomswdev
Copy link
Author

Do you have an outlook for the release date?

@me-no-dev
Copy link
Member

I have a few drivers to write first and there are things that need fixing in IDF before networking is stable anyway :)

@me-no-dev
Copy link
Member

interesting... I do not see any change that would break it and nobody else have reported it. Are you sure you are connected to the remote side?

@ccfoo242
Copy link

ccfoo242 commented Dec 9, 2016

I was just about to ask about this same error. Tried two different examples, one here https://developer.ibm.com/recipes/tutorials/connect-an-esp32-to-the-watson-iot-platform/ and one here https://learn.adafruit.com/adafruit-huzzah-esp8266-breakout/using-arduino-ide (changed the include to use just wifi.h

Similar error:
Reconnecting client to quickstart.messaging.internetofthings.ibmcloud.com
[E][WiFiClient.cpp:196] available(): 88

and
connecting to wifitest.adafruit.com
Requesting URL: /testwifi/index.html
[E][WiFiClient.cpp:196] available(): 88

Any help would be appreciated.

[Edit]
I think this is probably the error 88:
#define ENOTSOCK 88 /* Socket operation on non-socket */

@sorscode
Copy link
Contributor

sorscode commented Dec 9, 2016

I run MQTT on mine. Let me download the latest and reflash.

@sorscode
Copy link
Contributor

sorscode commented Dec 9, 2016

Okay, so I can confirm, I'm seeing the same thing now on the latest.

[E][WiFiClient.cpp:196] available(): 88

I have been running mine using MQTT for a few weeks, with no issues. I'll do so digging as well.

@sorscode
Copy link
Contributor

sorscode commented Dec 9, 2016

Okay, so I did some playing.

I was running on this commit:
commit 58ac6fb

Going to the latest it breaks. So I reverted back to the commit, that worked, and slowly moved forwards through the commits. The following commit, is the one that breaks it:
commit ee36407

So I now have moved mine to this commit (1 prior to the one above that breaks it):
commit e77ec63

I'm going to take a look around, and see if anything sticks out.

@sorscode
Copy link
Contributor

sorscode commented Dec 9, 2016

I haven't found anything yet. However, I do have a question. Is there a way to get more advanced/detailed debug output.

@HFRibeiro
Copy link

Is there any solution to this problem?

If we use the commit 58ac6fb it is possible to read the response from the server, but at the end of some connections, it is no longer possible to communicate getting:

[E][WiFiClient.cpp:62] connect(): socket: 23

@sorscode
Copy link
Contributor

I was running on 58ac6fb since release, with no issues. I'm now on e77ec63, and running strong. I am using dedicated power, versus USB.

@me-no-dev
Copy link
Member

The one major change that I see in the commit that you report as breaking things is the addition of "ethernet". Will ask around

@forthlightning
Copy link

I was also seeing this last night.
[E][WiFiClient.cpp:201] available(): 88

Running Arduino as a component, trying to connect to MQTT server via WiFi. I originally was using PubSubClient, and was going to change to mongoose today, but if It's a problem with Client, sounds like I should busy myself elsewhere.

@vshymanskyy
Copy link

I have the same problem

@suddenlyimaged
Copy link

I'm having same trouble it is connecting but it's not, I can see the esp32 on a wifi sniffer and arduino serial monitor shows it outputting.

@jlcook83
Copy link

Same issue here
[E][WiFiClient.cpp:196] available(): 88
I am using the Arduino IDE Wifi example modified to connect to data.sparkfun.com.

I will try manually merging the aforementioned commits onto my machine, that were reported 'working' - as a fix for now..

@sorscode
Copy link
Contributor

So I've been focused on this issue this weekend. The issue is in the TCP stack. I'm narrowing down where. The error, is on initial TCP connection to the MQTT server, and ever 15 seconds (Keep Alive timer). I did some deep packet, packet captures late last night. Will review today, and see what info I get from that, then go back into looking through the code.

I'm also going to try any reproduce, by trying something other than MQTT also.

I also have noticed, that on the last code that does work, it seems if you are doing too much communication over MQTT, it will lock the ESP32 up.

@sorscode
Copy link
Contributor

Just an update. I can recreate this on just a standard pull of data from a website. I used SparkFuns test example, for their ESP32 Thing device. It's when the data comes back to the ESP32, is when it throws the error 88. What I've noticed inside ESP32, is Error 88 means, Function not implemented.

I'm hoping to get to spend a little more time today on this.

@jlcook83
Copy link

jlcook83 commented Dec 18, 2016

@sorscode I appreciate you deep-diving into this, as I am sure others will as well. It certainty appears to be a problem even at the simplest implementations (such as the sparkfun's example) as you have mentioned.

*Even though I consider myself a seasoned c /c++ /etc troubleshooter, I am new to Espressif's line, and to the ESP-IDF, and is taking me some time to navigate through all the source - this gives me an appreciation for the progress you have made already!

I did perform a very simple test, by ignoring the error in WiFiClient.available(), and forcing it to still return a 'count' (it of course, is returning an invalid 'count') - to see if I could parse out a response from the server anyhow, and yes the server response is available (see below). Which, I guess means there is something going wrong much deeper past " int res = ioctl(sockfd, FIONREAD, &count);" .. this you already knew, I know, but just thought I'd mention the fact that parsing a response is somewhat possible - despite the garbage the error is also giving us..

int WiFiClient::available()
{
    if(!_connected) {
        return 0;
    }
    int count;
    int res = ioctl(sockfd, FIONREAD, &count);
    if(res < 0) {
        log_e("%d", errno);
       // stop();           <- Temporarily Ignoring
       // return 0;         <- Temporarily Ignoring
    }
    return count;
}

WiFi connected
IP address:
192.168.1.110
connecting to data.sparkfun.com
Requesting URL: /input/DJlxjN3VQmUxVY5m8Xqm?private_key=[MY PRIVATE KEY HERE]&data0=1

[E][WiFiClient.cpp:196] available(): 88 (+762 more occurrences..)

HTTP/1.1 200 OK

[E][WiFiClient.cpp:196] available(): 88 (+32 more occurrences..)

..A bunch of server responses here..

1 success

[E][WiFiClient.cpp:196] available(): 88 (+3 more occurrences..)

0

[E][WiFiClient.cpp:196] available(): 88 (+ infinite more...)

@sorscode
Copy link
Contributor

Okay so lots of progress today. I'm now able to make commit 48abb79 work. The issue doesn't seem to be code related at all, but an actual library. I haven't attempted yet to determine which one, but I might take a swing at that, after I post this.

So this is how I got it to work, after going through the entire Arduino Core.

Do the following: (Sorry in advance I'm a Mac user, so you will have to do the equivalent in other OS's.)
Go to the your esp32 folder, where you cloned too
git reset --hard e77ec63
copy the content of "tools/sdk/lib" to another folder (desktop is what I did)
return back to the root of your esp32 folder
git reset --hard 48abb79
copy the files that you just previously saved, back into "tools/sdk/lib". Don't remove the files that were there, just replace (count is different).

That is it. It will compile, and TCP functionality is restored. Mine has been running now for about 2 hours, and I've been sending it random MQTT commands, to do stupid stuff (ex. turn leds on/off, PWM on LEDs, and turn on relays).

Now time to see if I can determine which file(s), is causing the problem.

@MrSinan
Copy link

MrSinan commented Dec 19, 2016

İ confirm that the ersion 58ac6fb is running without problems on sparkfun ESP32 dev board. What is the big difference between this and the actual version???

@sorscode
Copy link
Contributor

MrSinan - what version of Arduino IDE are you running, and did you do this with or without my mod?

@jlcook83
Copy link

jlcook83 commented Dec 20, 2016

58ac6fb is working here too, not sure how I overlooked it, I'm certain I tried it at least once..
sorscode - I am having success without the mod...

EDIT:
It looks like b82d0e1 is where things really fall apart, at least for the problems I am seeing. In fact I can run right up to f4c2135, With 1d1aeec I just get constant CPU haults (although I don't think this is related directly to the error '88' in any way)

I'll do a bit more testing in the next few days to be certain b82d0e1 is the last place before I start getting WifiClient.available() Error 88's)

@sorscode
Copy link
Contributor

Interesting.

I'm going to blow my esp32 folder away, and try again, without modification. Then start working up the commit level again.

@sorscode
Copy link
Contributor

Okay, So I messed with this before I leave for work. I had to only apply the fix for only one of the commits, after that everything works fine up to e77ec63 (December 2nd, 2016). After that all produce the 88 error. If you are getting a CPU Panic or Halt, make sure you are not running off USB Power. I'm using a stable 5v Power Supply with 2A of available current to this board (ESP32 Dev).

So everyone is aware, I pulled down the IDF late last night, and going to work with that, to find this issue. I will focus on it tonight for a couple hours, when I get back from work.

@MrSinan
Copy link

MrSinan commented Dec 24, 2016

@sorscode: i use the last version arduino ide.

@sorscode
Copy link
Contributor

So I wanted to give an update. @me-no-dev and I have messed with this, and think a solution has been found. I'm running in the latest code, and working with no issues. I'm going to continue to test, and keep @me-no-dev updated, and hopefully have the fix in his next release.

@palomarcoder
Copy link

Appreciate all your work on this - how is it going?

@sorscode
Copy link
Contributor

Right now, I'm waiting on @me-no-dev to release the lastest revision with IDF to test. I have it working just fine use the IDF, with Arduino as a component. Once he pushes his change, I will test, and report back.

@palomarcoder
Copy link

If anyone would like help testing, let me know. I'm using the Arduino 1.8.0 IDE with the espressif esp32 core. I'm using wifi.begin, connect, status, localIP and also PubSubClient subscribe, publish, and callback.

I can also test udp begin, read, write functions.

@me-no-dev
Copy link
Member

currently working on the build process (something broke) and I'll test quickly the server/udp libs I have prepped. If they work, I'll merge them.

@me-no-dev
Copy link
Member

Updates are pushed, client is fixed, Server and UDP are added. I'm finally closing this

@palomarcoder
Copy link

I can confirm that it is working with the mqtt based IBM IoT Platform. Thanks!

@jlcook83
Copy link

Works great! Thanks for your efforts on this one @me-no-dev @sorscode

@ccfoo242
Copy link

Thank you!

@suddenlyimaged
Copy link

Working great on my Widora/eBox esp32 and running Blynk! Great work guys!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests