Skip to content

[I][WiFiClient.cpp:548] connected(): Unexpected: RES: 0, ERR: 119 (ESP32) #8

@DisasterofPuppets

Description

@DisasterofPuppets

I know this is setup for an ESP8266, however I can't seem to find anywhere else to help with the error message I am getting:

Description

Basically, this all works without issue on an ESP8266, but using the 32 I am able to connect to the twitch chat then my wifi disconnects and I get:

[I][WiFiClient.cpp:548] connected(): Unexpected: RES: 0, ERR: 119

Troubleshooting

Removing all the twitch code so it is just simple code to connect to the internet with wifi works without issue.
I have serial confirm the IP address every 5 minutes and can confirm it is connected to my router.
Could be related to the wifi.h and IRCClient.h being used together?

Board

I'm using a Wemos Lolin32 Lite , DOIT ESP32 Dev Kit V1 generic ESP32 etc.
Arduino 1.8.12

Sketch

/*******************************************************************
    Connect to Twtich Chat with a Bot

   Created with code from TheOtherLoneStar (https://www.twitch.tv/theotherlonestar)
   Hackaday IO: https://hackaday.io/otherlonestar

   By Brian Lough (https://www.twitch.tv/brianlough)
   YouTube: https://www.youtube.com/channel/UCezJOfu7OtqGzd5xrP3q6WA
 *******************************************************************/

#include <WiFi.h>          //https://github.com/esp8266/Arduino
#include <IRCClient.h>

//define your default values here, if there are different values in config.json, they are overwritten.

#define IRC_SERVER   "irc.chat.twitch.tv"
#define IRC_PORT     6667

//------- Replace the following! ------
char ssid[] = "ssid";       // your network SSID (name)
char password[] = "pass";  // your network key

//The name of the channel that you want the bot to join
const String twitchChannelName = "mytwitchchannel";

//The name that you want the bot to have
#define TWITCH_BOT_NAME "mytwitchbot"

//OAuth Key for your twitch bot
// https://twitchapps.com/tmi/
#define TWITCH_OAUTH_TOKEN "oauth:xxxxxxxxxxxxxxxxxxxxxx


//------------------------------


int led = LED_BUILTIN;
String ircChannel = "";

WiFiClient wiFiClient;
IRCClient client(IRC_SERVER, IRC_PORT, wiFiClient);

// put your setup code here, to run once:
void setup() {
  Serial.begin(115200);

  pinMode(led, OUTPUT);
  Serial.println();


  // Attempt to connect to Wifi network:
  Serial.print("Connecting Wifi: ");
  Serial.println(ssid);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    Serial.print(".");
    delay(500);
  }
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  IPAddress ip = WiFi.localIP();
  Serial.println(ip);

  ircChannel = "#" + twitchChannelName;

  client.setCallback(callback);
}

void loop() {

  // Try to connect to chat. If it loses connection try again
  if (!client.connected()) {
    Serial.println("Attempting to connect to " + ircChannel );
    // Attempt to connect
    // Second param is not needed by Twtich
    if (client.connect(TWITCH_BOT_NAME, "", TWITCH_OAUTH_TOKEN)) {
      client.sendRaw("JOIN " + ircChannel);
      Serial.println("connected and ready to rock");
      sendTwitchMessage("Oh no, that boi connected");
      delay(5000);
    } else {
      Serial.println("failed... try again in 5 seconds");
      // Wait 5 seconds before retrying
      delay(5000);
    }
    return;
  }
  client.loop();
}

void sendTwitchMessage(String message) {
  client.sendMessage(ircChannel, message);
}


void callback(IRCMessage ircMessage) {
  //Serial.println("In CallBack");

  if (ircMessage.command == "PRIVMSG" && ircMessage.text[0] != '\001') {
    //Serial.println("Passed private message.");
    ircMessage.nick.toUpperCase();

    String message("<" + ircMessage.nick + "> " + ircMessage.text);

    //prints chat to serial
    Serial.println(message);

    for (int i = 0; i < 6; i++) {
      digitalWrite(led, HIGH);
      delay(50);
      digitalWrite(led, LOW);
      delay(25);
    }

    return;
  }
}

###Debug message:

09:36:18.215 -> Connecting Wifi: SLOWKEVIN
09:36:18.215 -> [    58][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 0 - WIFI_READY
09:36:18.308 -> [   147][V][WiFiGeneric.cpp:97] set_esp_interface_ip(): Configuring Station static IP: 0.0.0.0, MASK: 0.0.0.0, GW: 0.0.0.0
09:36:18.355 -> [   145][V][WiFiGeneric.cpp:338] _arduino_event_cb(): STA Started
09:36:18.355 -> [   153][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 2 - STA_START
09:36:18.355 -> .[   419][V][WiFiGeneric.cpp:353] _arduino_event_cb(): STA Connected: SSID: MYWIFI, BSSID: 10:0c:6b:e2:89:b2, Channel: 1, Auth: WPA2_PSK
09:36:18.591 -> [   420][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 4 - STA_CONNECTED
09:36:18.827 -> ....[  2551][V][WiFiGeneric.cpp:367] _arduino_event_cb(): STA Got New IP:192.168.1.42
09:36:20.746 -> [  2551][D][WiFiGeneric.cpp:929] _eventCallback(): Arduino Event: 7 - STA_GOT_IP
09:36:20.746 -> [  2554][D][WiFiGeneric.cpp:991] _eventCallback(): STA IP: 192.168.1.42, MASK: 255.255.255.0, GW: 192.168.1.1
09:36:20.841 -> 
09:36:20.841 -> WiFi connected
09:36:20.841 -> IP address: 
09:36:20.841 -> 192.168.1.42
09:36:20.841 -> Attempting to connect to #Mytwitchchannel
09:36:21.077 -> connected and ready to rock
09:36:26.047 -> [  7885][I][WiFiClient.cpp:548] connected(): Unexpected: RES: 0, ERR: 119
09:36:26.047 -> [  7886][I][WiFiClient.cpp:548] connected(): Unexpected: RES: 0, ERR: 119

Lastly

This code and the things you provide have been so helpful in learning about Arduino and have helped me make a bunch of things I would never have dreamed of without the ideas and functionality of code like this !!! you ROCK!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions