Hi,
we are in a crisis. Our project is being submitted very soon and we have put a lot of effort into it.
Any help would be greatly appreciated!

We bought ESP8266 ESP-01 Wi-Fi module and we’re trying to connect it to our Firebase project by running the AT+CIPSTART command, but we’re getting an ERROR response from it, followed by a CLOSED response.

We could also connect to Firebase for about 5 months and up until a week and a half ago
A week and a half ago it worked few times, but after that, AT+CIPSTART returned ERROR CLOSED time after time.

Details:
1.We tried switching between different Wi-Fi networks and got the same results.
2.We can create TCP connections with HTTP websites.
3.We’re issuing AT commands to the Wi-Fi module via a STM32 microcontroller that is connected to it and to our Windows PC via a serial cable.
4.We’re using a terminal window in our PC to issue command to the Wi-Fi module.
5.We’re connecting to our AP, setting the SSL size to 4096 (helped solving some connectivity issues in the past), then connecting to Firebase.
6.We do not use AT project or certificate files
7.We use AT version: 1.1.0.0 (we found it by the command AT +GMR)

AT commands details:
AT+RST (reset the module)
AT+CWMODE=1 (set the Wi-Fi mode to station mode)
AT+CWJAP="SSID","PWD" (connect to a Wi-Fi network)
AT+CIFSR (get the Wi-Fi module IP)
AT+CIPSSLSIZE=4096 (change the SSL buffer size)
AT+CIPSTART="SSL","project-name-rtdb.firebaseio.com",443 (establish a SSL connection)
AT+CIPSEND=300 (send data)

Devices:
Wi-Fi module: MakerFocus ESP8266
STM32 microcontroller: STM32 Nucleo-64 board STM32F103RB

Reference:
ESP AT Commands Set

ESP8266 AT Instruction Set 3.0.3

THANK YOU!

Hi NemoResh ,

According to your description, you got errors on the SSL connection establishing stage (AT+CIPSTART). So I may suggest you debug the same stage from your PC using tools like telnet, curl, or openssl s_client.

Here is an example for validating SSL connection with openssl s_client on PC:
openssl s_client -crlf -verify_return_error -connect project-name-rtdb.firebaseio.com:443

If everything will be okay on PC, try to use WireShark to debug network failures when your ESP sends network packets. I think it can be achieved when you start a WiFi network on your notebook and setup WireShark to sniff packets on that new wlan network interface.

kial
Thanks for your response!
When I write openssl s_client -crlf -verify_return_error -connect project-name-rtdb.firebaseio.com:443,
the things that are returned in the terminal are:

CONNECTED(00000004)
....
Certificate chain
....
Server certificate
....

How can I know where the problem is?
kial, thanks again

    NemoResh
    If you don't see any "error" words in the output - so the issue is not reproduced on your PC.
    Looks like there are no SSL errors with endpoint project-name-rtdb.firebaseio.com:443

    You have to test the second option with WireShark to debug what is causing connection error

    kial We did not find ESP facts. Could it be that they could not be tracked?

    • kial replied to this.

      kial Yes, sorry. I meant that we tried using Wireshatk but where not able to capture ESP packets. We found that other people had the same issue with wireshark. Do you know how to enable the packet capture for ESP?

        NemoResh, please read carefully the last part of the message kial

          6 days later

          kial Thanks for your suggestions.
          Just to be on the same page and to clarify what @NemoResh wrote in the first post, the Wi-Fi module is a ESP8266 based module that isn't running an OS. It is connected to a STM32 microcontroller, which is connected to a PC with a serial cable. Controlling the Wi-Fi module is done by issuing AT commands from a terminal (via COM port) in that PC.
          In other words, unfortunately Wireshark isn't an option.

          Any other advice?
          Thank you

            OzEdri, my idea is to sniff network packets sent through the WiFi connection started by the ESP.
            I suggest to start WiFi hotspot on the notebook/PC connected to the internet through the another channel (like Ethernet cable), then connect ESP to that WiFi hotspot.
            So the notebook/PC will be a "man in the middle" able to run Wireshark.
            What do you think?

              kial Thank you for this clarification. Running Wireshark to sniff WLANs is very setup-dependant (see Capturing packets on wireless LANs and WLAN (IEEE 802.11) capture setup).
              That's why we considered looking for other packet capturing tools that are more designated for this task.

              That said, I'd like to add an important note that is missing in the first post - it's possible to successfully establish SSL connection to other sites by running the AT+CIPSTART="SSL" command, so we can understand we're missing something in the TLS handshake with Firebase, maybe version related.
              That assumption is also based on multiple similar issues that are reported in Espressif's ESP8266_NONOS_SDK issues page in Git Hub,

              Do you happen to know if there's a way to get more information from the Wi-Fi module behind the "ERROR" output we're getting by issuing AT commands other than packet capturing?

                OzEdri, you can use a WiFi hotspot only to make PC a gateway to Firebase, and sniff packets outgoing from the PC to Firebase. This part of communication should be more stable unlike WiFi sniffing

                  a year later
                  Write a Reply...