[Python] ESP32/ESP8266 Supabase Connection Issues: Error -116 and HTTP 400 [closed]

Discussão em 'Python' iniciado por Stack, Abril 3, 2025.

  1. Stack

    Stack Membro Participativo

    I'm developing an IoT emergency system using ESP32/ESP8266 with both LoRa and WiFi connectivity that connects to a Supabase database. While the device successfully connects to WiFi and sends LoRa messages, it fails to communicate with Supabase with two specific errors:

    1. Error -116 when trying to PATCH user status
    2. HTTP 400 with message Empty or invalid json when trying to POST an alert
    Code


    My project code is available at: https://gist.github.com/52db608b92f7b09f97e025673b1b6f38.git

    Error Log


    Sending LoRa: MODERATE_SOS,0,NO_GPS
    LoRa message sent
    Connecting to WiFi...
    Connected to WiFi. IP: 192.168.137.248
    Supabase request: PATCH https://aoeghkltxfbencifjgsb.supabase.co/rest/v1/sos_user?id=eq.181235ff-4771-44a5-b3af-29b17a6a997a
    Supabase request error: -116
    Retrying status update...
    Supabase request: PATCH https://aoeghkltxfbencifjgsb.supabase.co/rest/v1/sos_user?id=eq.181235ff-4771-44a5-b3af-29b17a6a997a
    Supabase request error: -116
    Failed to update status to 'SOS'
    Supabase request: POST https://aoeghkltxfbencifjgsb.supabase.co/rest/v1/sos_alerts
    Supabase response status: 400
    Supabase error: 400
    Error details: {'code': 'PGRST102', 'message': 'Empty or invalid json', 'hint': None, 'details': None}
    Failed to create SOS Alert
    WiFi disconnected

    What I've Tried

    • Verified WiFi connection is stable (successfully connects with IP 192.168.137.248)
    • Confirmed LoRa messages are being sent successfully
    • Double-checked Supabase endpoint URLs and authentication
    • Attempted retry for the status update
    Environment

    • Hardware: ESP32/ESP8266
    • Connectivity: WiFi and LoRa
    • Database: Supabase
    • Endpoints:
      • PATCH /rest/v1/sos_user?id=eq.181235ff-4771-44a5-b3af-29b17a6a997a
      • POST /rest/v1/sos_alerts
    Questions

    1. What does error code -116 indicate when using ESP8266HTTPClient/ESP32HTTPClient?
    2. How can I fix the "Empty or invalid json" error when posting to Supabase?
    3. Are there any specific headers or authentication requirements I might be missing for Supabase REST API?

    Continue reading...

Compartilhe esta Página