Skip to content

AsyncMQTT & OTA does not work together #5857

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
6 tasks done
rohitjust24idpl opened this issue Mar 9, 2019 · 6 comments
Closed
6 tasks done

AsyncMQTT & OTA does not work together #5857

rohitjust24idpl opened this issue Mar 9, 2019 · 6 comments

Comments

@rohitjust24idpl
Copy link

Hi @igrr @marvinroger @me-no-dev @d-a-v,

Basic Infos

  • This issue complies with the issue POLICY doc.
  • I have read the documentation at readthedocs and the issue is not addressed there.
  • I have tested that the issue is present in current master branch (aka latest git).
  • I have searched the issue tracker for a similar issue.
  • If there is a stack dump, I have decoded it.
  • I have filled out all fields below.

Platform

  • Hardware: [ESP-12]
  • Core Version: [2.4.2]
  • Development Env: [Arduino IDE]
  • Operating System: [MacOS]

Settings in IDE

  • Module: [Generic ESP8266 Module]
  • Flash Mode: [qio]
  • Flash Size: [4MB/3MB]
  • lwip Variant: [v2 Higher Bandwidth]
  • Reset Method: [nodemcu]
  • Flash Frequency: [40Mhz]
  • CPU Frequency: [80Mhz]
  • Upload Using: [SERIAL]
  • Upload Speed: [115200] (serial upload only)

Problem Description

Using following libraries
MQTT: AsyncMQTT (OVER SSL)
OTA: ESP8266httpUpdate

Observations as follows

image

Scenario 1

  1. As per the comments in #1676,I tried to tweak the settings and lwip v1.4 worked for me for OTA.
  2. But MQTT crashes when try to connect and throws exception (29).

Scenario 2

  1. MQTT works on lwip v2. OTA also works on select ISP where network is stable.
  2. But throws Stream Read Timeout while updating in few ISPs where network is unstable.

NOTE: I am sure this is not a memory issue. I am using the example sketches mentioned in the libraries.

Currently I am stuck how to get these two things work together.
Looking forward for your response. Any help is appreciated.

Debug Messages

Exception (29):
epc1=0x40210242 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000004 depc=0x00000000

Update error: ERROR[6]: Stream Read Timeout

@dzmpr
Copy link

dzmpr commented Mar 9, 2019

Seems I have same problem #5818. But I trying update clear ESP over HTTPS and also getting read timeout. Over HTTP updates ok. Using lwip v1.4 lm.

@devyte
Copy link
Collaborator

devyte commented Mar 12, 2019

@rohitjust24idpl said:

But throws Stream Read Timeout while updating in few ISPs where network is unstable.

If memory serves, there is a timeout somewhere for Streaming, which signifies max time allowed between two consecutive read attempts.
What happens if you increase that timeout?
(@d-a-v do you remember where the timeout is?)

@rohitjust24idpl
Copy link
Author

@devyte

What happens if you increase that timeout?

ESP8266httpUpdate.cpp: Tried to increase this timeout does not works.

ESP8266HTTPUpdate::ESP8266HTTPUpdate(void)
        : _httpClientTimeout(8000)
{
}

Stream.cpp: Tried to increase this timeout does not works.

void Stream::setTimeout(unsigned long timeout)  // sets the maximum number of milliseconds to wait
{
    _timeout = timeout;
}

Updater.cpp : I see here it attempts twice to read bytes before assigning UPDATE_ERROR_STREAM error. I tried increasing the number of attempts or timeout in data.readbytes both. But it doesn't seems to work. Your thoughts ?

    while(remaining()) {
        toRead = data.readBytes(_buffer + _bufferLen,  (_bufferSize - _bufferLen));
        if(toRead == 0) { //Timeout
            delay(100);
            toRead = data.readBytes(_buffer + _bufferLen, (_bufferSize - _bufferLen));
            if(toRead == 0) { //Timeout
                _currentAddress = (_startAddress + _size);
                _setError(UPDATE_ERROR_STREAM);
                _reset();
                return written;
            }
        }
        _bufferLen += toRead;
        if((_bufferLen == remaining() || _bufferLen == _bufferSize) && !_writeBuffer())
            return written;
        written += toRead;
        yield();
    }

Please guide me which timeout to set ?

@Swiftnesses
Copy link

I'm also interested in knowing this as I have issues with V2...

@b-rohit
Copy link

b-rohit commented Sep 16, 2019

I also have the same issue on ESP8266 nodemcu and Wimex.

@earlephilhower
Copy link
Collaborator

Closing due to no MCVE, no decoded stack dump, and age. There's unfortunately nothing we can do with the little info in this issue.

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

6 participants