areve / WebSocketStreamClient

10 stars 10 forks source link

Example: error: cannot declare variable 'wsStreamClient' to be of abstract type 'WebSocketStreamClient' #4

Closed fightforlife closed 3 years ago

fightforlife commented 4 years ago

Hi Areve,

this is the only library on the whole internet I could find, which supports MQTT over WSS.

Sadly the example is not working for me, do zou have an idea?

error: cannot declare variable 'wsStreamClient' to be of abstract type 'WebSocketStreamClient' WebSocketStreamClient wsStreamClient(wsClient, path);

WebSocketStreamClient.h:8:7: note: because the following virtual functions are pure within 'WebSocketStreamClient': class WebSocketStreamClient : public Client

esp8266\hardware\esp8266\2.7.1\cores\esp8266/Client.h:37:22: note: virtual void Client::flush() virtual void flush() = 0;

exit status 1 cannot declare variable 'wsStreamClient' to be of abstract type 'WebSocketStreamClient'

clysss commented 3 years ago

Compiled with esp8266 board version 2.5.0 is OK With 2.7 => Error

clysss commented 3 years ago

I DID THE DIRTY WAY : OK to compile with 2.7.x (and last pubsibclient) if :

PS : Areve, you're a genius. You're idea of implementing client.h that way is just beautifull Thanks

areve commented 3 years ago

Sorry, don't have time, nor need to maintain this library. I'm really happy it's helped others though. May clysss's fork live forever!

clysss commented 3 years ago

just a question areve : when mqtt msg size is over 128b, the WS hang, because of iTxBuffer[128] in websocket.h (websocketclient private var) Is there a way to overwrite this without modifyng websocket.h (li tried like you did with websocket250 without success : compile is OK but itxbuffer[128] is still used by the parent class)..

mer30boy commented 3 years ago

hi clysss I used the library forked by you. I execute your example in arduino IDE ( Nodemcu ) and mqtt connect succesfully. but the "onMqttPublish" function is never executed and I do not receive any (published) message. I also tested with my own personalized mqtt broker and the result was similar.

clysss commented 3 years ago

Hello, I don't know why you're having this issue. Could it be linked to the mqtt server? (I don't see any error in the example, but remember never used it directly) I'm using everyday this lib without issue on esp8266. My code was before on standard port, and working, and just update it to ws Perhaps give me more info on your environment

Le dim. 14 mars 2021 à 12:16, mer30boy @.***> a écrit :

hi clysss I used the library forked by you https://github.com/clysss/WebSocketStreamClient. I execute your example https://github.com/clysss/WebSocketStreamClient/blob/master/examples/example-mqtt-ws/example-mqtt-ws.inoin arduino IDE ( Nodemcu ) and mqtt connect succesfully. but the "onMqttPublish" function is never executed and I do not receive any (published) message. I also tested with my own personalized mqtt broker and the result was similar.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/4#issuecomment-798888834, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKVWKSL6OYABQ5YXLWYJETTDSLIFANCNFSM4NDK4QZQ .

mer30boy commented 3 years ago

I think this problem is related to pubsubclient's library. Because when I searched for this problem, I came to the results of the pubsubclient's library. What version of pubsubclient's Library do you use?

clysss commented 3 years ago

2.8.0

Le dim. 14 mars 2021 à 15:16, mer30boy @.***> a écrit :

I think this problem is related to pubsubclient's library. Because when I searched for this problem, I came to the results of the pubsubclient's library. What version of pubsubclient's Library do you use?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/4#issuecomment-798915366, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKVWKVYHU64JDQS2M4CCKTTDTANBANCNFSM4NDK4QZQ .

mer30boy commented 3 years ago

hi I solved the previous problem by calling this function: mqtt.setBufferSize(5000); But there is still another problem: I want to publish a message. If the number of characters in the message is less than 128 characters, everything will work fine. But if the message length is more than 128 characters, the message will not be sent and the mqtt connection will be disconnected.

This is part of your library's README.MD:

<!> IF the size of MQTT MESSAGE is > 128 bytes, the websocket hang => add (pubsubclient) .setBufferSize(512) => change in websocket.h iTxBuffer[512]

as I said I set .setBufferSize function. but where is websocket.h file ?

clysss commented 3 years ago

In your library files...

Le mer. 17 mars 2021 à 08:01, mer30boy @.***> a écrit :

hi I solved the previous problem by calling this function: mqtt.setBufferSize(5000); But there is still another problem: I want to publish a message. If the number of characters in the message is less than 128 characters, everything will work fine. But if the message length is more than 128 characters, the message will not be sent and the mqtt connection will be disconnected.

This is part of your library's README.MD:

<!> IF the size of MQTT MESSAGE is > 128 bytes, the websocket hang => add (pubsubclient) .setBufferSize(512) => change in websocket.h iTxBuffer[512]

as I said I set .setBufferSize function. but where is websocket.h file ?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/4#issuecomment-800847674, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKVWKXFYKQXIOBF3P73543TEBHUVANCNFSM4NDK4QZQ .

mer30boy commented 3 years ago

what library ? There is no file as 'websocket.h' in these libraries! This is a list of files available in libraries:

PubSubClient library:

PubSubClient.cpp PubSubClient.h

WebSocketStreamClient lib

WebSocketStreamClient.h

also I don't find 'iTxBuffer' in these files .

clysss commented 3 years ago

How to search for a file name?

Le mer. 17 mars 2021 à 08:55, mer30boy @.***> a écrit :

what library ? There is no file as 'websocket.h' in these libraries! This is a list of files available in libraries:

PubSubClient https://github.com/knolleary/pubsubclient library:

PubSubClient.cpp PubSubClient.h

WebSocketStreamClient https://github.com/knolleary/pubsubclient lib

WebSocketStreamClient.h

also I don't find 'iTxBuffer' in these files .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/areve/WebSocketStreamClient/issues/4#issuecomment-800876282, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANKVWKS7G56KTK2QUB5GLQLTEBN5TANCNFSM4NDK4QZQ .