Coder Social home page Coder Social logo

connect() timeout about arduinowebsockets HOT 4 CLOSED

RainGrid avatar RainGrid commented on July 24, 2024
connect() timeout

from arduinowebsockets.

Comments (4)

adelin-mcbsoft avatar adelin-mcbsoft commented on July 24, 2024

Hi @RainGrid ,

Take a look at this topic (issue no. #14).
It might be related to it and it may shed some light.

Thanks,
Best,
A.

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on July 24, 2024

Hi, that's odd...
I'm running this sketch (credentials intentionally invalid):

#include <ArduinoWebsockets.h>
#include <WiFi.h>

const char* ssid = "ssid"; //Enter SSID
const char* password = "password"; //Enter Password

using namespace websockets;

WebsocketsClient client;
void setup() {
    Serial.begin(115200);
    // Connect to wifi
    WiFi.begin(ssid, password);

    // Wait some time to connect to wifi
    for(int i = 0; i < 10 && WiFi.status() != WL_CONNECTED; i++) {
        Serial.print(".");
        delay(1000);
    }

    // Check if connected to wifi
    if(WiFi.status() != WL_CONNECTED) {
        Serial.println("No Wifi!, But lest keep going");
    }

    Serial.println("Connected to Wifi, Connecting to server.");
    // try to connect to Websockets server
    bool connected = client.connect("ws://1.2.3.4:8080");
    if(connected) {
        Serial.println("Connecetd!");
        client.send("Hello Server");
    } else {
        Serial.println("Not Connected!");
    }
    
    // run callback when messages are received
    client.onMessage([&](WebsocketsMessage message){
        Serial.print("Got Message: ");
        Serial.println(message.data());
    });
}

void loop() {
    // let the websockets client check for incoming messages
    if(client.available()) {
        client.poll();
    }
    delay(500);
}

And the program runs just fine, and prints "Not Connected!".
Please make sure you really do have the latest library version (write here what you have), and make sure you have the latest esp32 libs (1.0.4 is the latest stable, which I have).
If all that does not help, turn on debugging logs and lets see what's up :)

Thanks for opening the issue,
Gil.

from arduinowebsockets.

RainGrid avatar RainGrid commented on July 24, 2024

@gilmaimon hi, you are right, the problem was in the Esp lib (v 1.0.2). Works well with v 1.0.4. Thanks for the help.

from arduinowebsockets.

gilmaimon avatar gilmaimon commented on July 24, 2024

Awesome! I'm glad I could help and thanks for taking the time to open the issue.

Gil.

from arduinowebsockets.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.