Skip to content

Exception in WiFiClient when WiFi is disconnected #4078

Closed
@pakokol

Description

@pakokol

Basic Infos

Hardware

Hardware: ESP-WROOM-02
Core Version: 2.4.0

Description

WiFiClient causes exception 28 in connect function.

Settings in IDE

Module: Generic ESP8266 Module
Flash Size: 2M
CPU Frequency: 80Mhz
Flash Mode: DIO
Flash Frequency: 40Mhz
Upload Using: SERIAL
Reset Method: ck

Sketch

#include <ESP8266WiFi.h>
#include <Esp.h>

const char *ssid      = "MySSID";
const char *password  = "MyPass";

const char *serverIP  = "192.168.1.106";
const int  serverPort = 1883;

WiFiClient client;

void toggleLED()
{
  pinMode(5, OUTPUT);
  digitalWrite(5, HIGH);
  delay(250);
  digitalWrite(5, LOW);
  delay(250);
}

void setup() {
  // put your setup code here, to run once:
    Serial.begin(115200);
    WiFi.setOutputPower(20.5);
    WiFi.mode(WIFI_STA);
    WiFi.begin(ssid, password);
}

void loop() {
  if(WiFi.status() == WL_CONNECTED)
  {
    Serial.println("Connected to WiFi");
    if(!client.connect(serverIP, serverPort))
    {
      Serial.println("Can't connect client.");
    }
    else
    {
      Serial.println("Client connected."); 
    }
  }
  else
  {
     Serial.println("Not connected to WiFi");
  }
  
  toggleLED();
}

Debug Messages

Exception (28):
epc1=0x40202af1 epc2=0x00000000 epc3=0x00000000 excvaddr=0x000000bb depc=0x00000000

ctx: cont 
sp: 3ffefcd0 end: 3ffeff00 offset: 01a0
>>>stack>>>
3ffefe70:  3ffeec58 00000000 3fff112c 40202aea 
3ffefe80:  6a01a8c0 00000010 3ffe8880 3ffeeecc  
3ffefe90:  3fffdad0 00000011 3ffeeea0 3ffeeecc  
3ffefea0:  3fffdad0 0000075b 3ffeec58 402026a8 
3ffefeb0:  3ffe8bf0 6a01a8c0 3ffe8bf0 6a01a8c0  
3ffefec0:  3ffe88c8 40202460 3ffeeea0 40203198 
3ffefed0:  00000000 00000000 3ffeeea0 40202132
3ffefee0:  3fffdad0 00000000 3ffeeec4 40203404
3ffefef0:  feefeffe feefeffe 3ffeeee0 40100710 
<<<stack<<<<
 ets Jan  8 2013,rst cause:1, boot mode:(3,6)

load 0x4010f000, len 1384, room 16 
tail 8
chksum 0x2d
csum 0x2d

I'm trying to connect to a MQTT server. It connects to the server and works as expected. But when I turn of my router and the connection is lost it crashes with exception 28. Am I using something wrong or is this a bug?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions