areve / WebSocketStreamClient

10 stars 10 forks source link

Esp32 support #3

Open rickgrael opened 4 years ago

rickgrael commented 4 years ago

Does this lib support ESP32? I'm trying to connect to a server hosted in heroku. This server container a MOSCA broker, but pubsubclient does not support ws: connection.

areve commented 4 years ago

Sorry I don't know, I used it for one project only.

On Sat, 18 Apr 2020, 13:15 rickgrael, notifications@github.com wrote:

Does this lib support ESP32? I'm trying to connect to a server hosted in heroku. This server container a MOSCA broker, but pubsubclient does not support ws: connection.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/3, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGQGQTIIMVZZPN3U355TATRNGKXBANCNFSM4MLKSG2Q .

sespivak commented 3 years ago

Yes, it works with ESP32! Here is tested code, that works with ws and wss:

#include <PubSubClient.h>
#include <WiFiClientSecure.h>
#include "WebSocketClient250.h"
#include "WebSocketStreamClient.h"

/* MQTT credentials */
const char* mqtt_host = MQTT_HOST;
const int   mqtt_port = MQTT_PORT;
const char* mqtt_path = MQTT_PATH;
const char* mqtt_id   = MQTT_ID;
const char* mqtt_user = MQTT_USER;
const char* mqtt_pass = MQTT_PASS;

/* create an instance of PubSubClient client */
WiFiClientSecure espClient;
WebSocketClient250 wsClient(espClient, mqtt_host, mqtt_port);
WebSocketStreamClient wsStreamClient(wsClient, mqtt_path);
PubSubClient mqtt_client(wsStreamClient);

void mqtt_init(void) {
  // don't check sign chain
  espClient.setInsecure();
}

void mqtt_connect() {
  /* connect now */
  if (mqtt_client.connect(mqtt_id, mqtt_user, mqtt_pass)) {
    Serial.println("mqtt connected");
  }
}
clysss commented 2 years ago

Great news 👍 could you tell me what version of esp32 board (arduino ide?) are you using ? You can also have a look to https://github.com/clysss/WebSocketStreamClient make caution to buffer size in websocket.h just received a proposed update of this file : https://github.com/arduino-libraries/ArduinoHttpClient/issues/68#issuecomment-1021150686

sespivak commented 2 years ago

Great news 👍 could you tell me what version of esp32 board (arduino ide?) are you using ?

Hi, @clysss! I've used it with TTGO T-Call V1.3 ESP32 board in Platformio IDE. Here is the project config:

[env:esp32]
platform = espressif32
board =  esp-wrover-kit
framework = arduino
monitor_speed = 115200
upload_protocol = espota
lib_deps = TinyGSM
           PubSubClient
           ESP32Ping
           WiFiClientSecure
           ArduinoHttpClient
clysss commented 2 years ago

Thanks:) Is it 2.0.2 version of https://github.com/espressif/arduino-esp32 ?

Le jeu. 27 janv. 2022 à 11:29, sespivak @.***> a écrit :

Great news 👍 could you tell me what version of esp32 board (arduino ide?) are you using ?

Hi, @clysss https://github.com/clysss! I've used it with TTGO T-Call V1.3 ESP32 board in Platformio IDE. Here is the project config:

[env:esp32]

platform = espressif32

board = esp-wrover-kit

framework = arduino

monitor_speed = 115200

upload_protocol = espota

lib_deps = TinyGSM

       PubSubClient

       ESP32Ping

       WiFiClientSecure

— Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/3#issuecomment-1023063247, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKVWKWLSJZDIFNDGC45SRLUYEM7TANCNFSM4MLKSG2Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

sespivak commented 2 years ago

Thanks:) Is it 2.0.2 version of https://github.com/espressif/arduino-esp32 ?

This one: https://github.com/platformio/platform-espressif32/releases/tag/v3.4.0

clysss commented 2 years ago

Hmm yes:) of course, sorry! Thansks to have point me the difference, i'll have to try with platform io :) perhaps to move to..

May i ask you to try to compile using classical socket and not xxx250 like in the sample of my fork?

Le jeu. 27 janv. 2022 à 12:55, sespivak @.***> a écrit :

Thanks:) Is it 2.0.2 version of https://github.com/espressif/arduino-esp32 ? This one: https://github.com/platformio/platform-espressif32/releases/tag/v3.4.0

— Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/3#issuecomment-1023131621, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKVWKQHV2A7GBWM6GDBXV3UYEXEDANCNFSM4MLKSG2Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

paclema commented 2 years ago

@clysss I have proposed this ws tx buffer size redefinition in order to make your https://github.com/clysss/WebSocketStreamClient works with bigger messages. I confirm that I have used platform io and esp32 target and it works after increasing this buffer.

clysss commented 2 years ago

Thanks a lot Pablo:) with your information, I've been able to correctly make my board working (my issue was not on websoketstream but a bad return after a publish...) with last firmware :)

Le lun. 31 janv. 2022 à 12:49, Pablo Clemente Maseda < @.***> a écrit :

@clysss https://github.com/clysss I have proposed this ws tx buffer size redefinition in order to make your https://github.com/clysss/WebSocketStreamClient works with bigger messages. I confirm that I have used platform io and esp32 target and it works after increasing this buffer.

— Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/3#issuecomment-1025656590, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKVWKTFWEABZFLZ362M52LUYZZLJANCNFSM4MLKSG2Q . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

fabltd commented 1 year ago

@clysss

Should you fix still work? It all complies but I cannot connect.

clysss commented 1 year ago

Yes it works correctly!

Le ven. 9 juin 2023, 22:49, Jeremy @.***> a écrit :

@clysss https://github.com/clysss

Should you fix still work? It all complies but I cannot connect.

— Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/3#issuecomment-1585111351, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKVWKWIV3TOSXSZAILMSATXKOD6VANCNFSM4MLKSG2Q . You are receiving this because you were mentioned.Message ID: @.***>

fabltd commented 1 year ago

Any tips to see why it's not working? I just don't get a connection

clysss commented 1 year ago

Use open tool to verify the websocket / at least your browser. Firewall?

Le ven. 9 juin 2023, 23:13, Jeremy @.***> a écrit :

Any tips to see why it's not working? I just don't get a connection

— Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/3#issuecomment-1585135114, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKVWKXCS4JADFRIO2JNOIDXKOGYFANCNFSM4MLKSG2Q . You are receiving this because you were mentioned.Message ID: @.***>

fabltd commented 1 year ago

I can connect no problem with another client.

Tried with both:

WiFiClientSecure wiFiClient; WiFiClient wiFiClient;

Does the host need to have ws:// specifed ?

currenly i have the following

static const char *host = "192.168.100.201";

Host is running on local lan and works fine with other websocket clients.

fabltd commented 1 year ago

@clysss I see in wireshark 400 bad request.

Somehow WS fails. I have no idea why

clysss commented 1 year ago

i declare something like this : WiFiClientSecure wifiClient; WebSocketClient wsClient(wifiClient, "toto.ccc.com", 443); WebSocketStreamClient wsStreamClient(wsClient, mqttPath); PubSubClient MQTTClient(wsStreamClient);

On Mon, 12 Jun 2023 at 18:03, Jeremy @.***> wrote:

@clysss https://github.com/clysss I see in wireshark 400 bad request.

Somehow WS fails. I have no idea why

— Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/3#issuecomment-1587629904, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKVWKRE355LK3DPUGKAAALXK44UDANCNFSM4MLKSG2Q . You are receiving this because you were mentioned.Message ID: @.***>

fabltd commented 1 year ago

@clysss

Yes thats how i did it. It just refuses to connect to emqx:

WiFiClient wiFiClient;
WebSocketClient wsClient(wiFiClient, host, port);
WebSocketStreamClient wsStreamClient(wsClient, path);
PubSubClient client(wsStreamClient);
clysss commented 1 year ago

And you change the buffer size?

Le lun. 12 juin 2023, 22:45, Jeremy @.***> a écrit :

@clysss https://github.com/clysss

Yes thats how i did it. It just refuses to connect to emqx:

WiFiClient wiFiClient; WebSocketClient wsClient(wiFiClient, host, port); WebSocketStreamClient wsStreamClient(wsClient, path); PubSubClient client(wsStreamClient);

— Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/3#issuecomment-1588065306, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKVWKQANFGYJHVBHIDVI7DXK55U5ANCNFSM4MLKSG2Q . You are receiving this because you were mentioned.Message ID: @.***>

clysss commented 1 year ago

If the websocket is supposed to be ssl-ed, use wificlientsecure...

Le lun. 12 juin 2023, 22:50, clysss @.***> a écrit :

And you change the buffer size?

Le lun. 12 juin 2023, 22:45, Jeremy @.***> a écrit :

@clysss https://github.com/clysss

Yes thats how i did it. It just refuses to connect to emqx:

WiFiClient wiFiClient; WebSocketClient wsClient(wiFiClient, host, port); WebSocketStreamClient wsStreamClient(wsClient, path); PubSubClient client(wsStreamClient);

— Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/3#issuecomment-1588065306, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKVWKQANFGYJHVBHIDVI7DXK55U5ANCNFSM4MLKSG2Q . You are receiving this because you were mentioned.Message ID: @.***>

fabltd commented 1 year ago

Have tried with and without SSL. Still no connection

clysss commented 1 year ago

No more ideas, sorry

Le lun. 12 juin 2023, 23:52, Jeremy @.***> a écrit :

Have tried with and without SSL. Still no connection

— Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/3#issuecomment-1588155397, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKVWKWFFZRLFSFDG72PUY3XK6FSXANCNFSM4MLKSG2Q . You are receiving this because you were mentioned.Message ID: @.***>