Connected to Wi-Fi network, but Arduino Cloud says Device is "offline"

I'm using a nano esp32 board and I'm also experiencing the same problem as you, have you solved it yet?
Here is my code:

// Code generated by Arduino IoT Cloud, DO NOT EDIT.

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>

const char DEVICE_LOGIN_NAME[]  = "*************";

const char SSID[]               = SECRET_SSID;    // Network SSID (name)
const char PASS[]               = SECRET_OPTIONAL_PASS;    // Network password (use for WPA, or use as key for WEP)
const char DEVICE_KEY[]  = SECRET_DEVICE_KEY;    // Secret device password

void onWeightChange();
void onIscloseChange();
void onIsopenChange();

float Weight;
bool isclose;
bool isopen;

void initProperties(){

  ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
  ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
  ArduinoCloud.addProperty(Weight, READWRITE, ON_CHANGE, onWeightChange);
  ArduinoCloud.addProperty(isclose, READWRITE, ON_CHANGE, onIscloseChange);
  ArduinoCloud.addProperty(isopen, READWRITE, ON_CHANGE, onIsopenChange);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

In my serial port information it shows that I'm connected to the wireless network, but in the Arduino Cloud interface it shows that my device is still offline.

Hi @jjjyyyooo. Please post your full sketch.

I'll provide instructions you can follow to do that:

  1. Do an Auto Format on your code by pressing Ctrl+B.
    This is done to make the code easier for us to read.
  2. Click on the window that contains your sketch code.
  3. Press the Ctrl+A keyboard shortcut.
    This will select all the text.
  4. Press the Ctrl+C keyboard shortcut.
    This will copy the selected text to the clipboard.
  5. Open a forum reply here by clicking the "Reply" button.
  6. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code block icon on toolbar
  7. Press the Ctrl+V keyboard shortcut.
    This will paste the copied code into the code block.
  8. Move the cursor outside of the code block markup before you add any additional text to your reply.
  9. Repeat the above process if your sketch has multiple tabs.
  10. Click the "Reply" button to post the output.

When your code requires a library that's not pre-installed in "Arduino Cloud Editor", please post a link to where you downloaded that library from.