WebSocket Client Extension


#14

OK I found the problem. It did not work with the outdated companion. Everything is fine now.


#15

Hi @grexhh,
I checked my companion is the last version (as for Google Play) and tried again without luck.
To be more precise, the companion connection throws an empty error (but seems to connect), it can send a message to the server but it doesn’t get any reply from the server.
I don’t get this behavior when using wss://echo.websocket.org though, so I guess I’m missing something related to nodered / appybuilder setups.

Would you please show complete basic working blocks and nodered nodes?
Thank you very much :slight_smile:


#16

ws://echo.websocket.org


#17

@j2l sorry I guess I can’t help here. I switched to using UDP and do not have anything to show. I am also not using nodered.


#18

I made an arduino code that directly with websokets an esp32 that is the objective ??


#19

@Andres_Cotes
Coming back to this one because I think firebase sucks.
I made it kinda works after ignoring error totally BUT
I pinpoined 2 problems:

  • error message is empty (nothing) and fires even when connection is actually working.
  • the onMessage is never firing even when other clients receive a broadcast message.

I updated everything (clients, server (not localhost)) and tried with various clients (websocket chrome extension, web client, server’s injection). All receive messages from each other EXCEPT this extension’s onMessage.
I also tried to stringify the JSON object message, without luck.

Should I switch to the great tutorial about pubnub? It’s not 2015 anymore :slight_smile:


#20

No, I made my own websocket server.
No arduino in the loop this time :wink: (BTW, I just received components for my arduino water softener).


#21

The block “GetSecret”. For what is its function?


#22

If I use this Extension, Can I get image from server? The server is made with PYTHON and I just need to connect to the server, Click the button -> get image to my application.


#23

Hello , Andreas
your WebSocket extension seems to be the only working of its kind .
I would like to use it for a simple app to control a relay on ESP8266 : I have already one working but without Websocket , which is a totally new and confusing matter to me now.
Could you show a sample on how correctly use those blocks, to help better understanding ?
Any suggestion would be really appreciated .

Thank you so much

Fabio


#25

Hi Sven ,
yes , I did it and it is now running on two apps of mine : a relay with temperature sensor and a food distributor for my cats I interfaced to remotely operate and get feedback…
It’s actually much a faster response than I expected…
If I can be of any help, let me know…
Regards
Fabio.


#26

My mistake, it works now! Thanks for your reply!
I had tried another websocket extension before, it was buggy and somehow I mixed the two.
I now get my readings displayed quickly and reliably.

Yesterday I installed my app on the mobile phone of a colleague and it crashes immediately with the connection setup.
He has a Galaxy S10e with Android 9.
With Android 9 and Appybuilder there still seem to be problems, but I don’t know exactly where the problem lies.
At the beginning I use Taifun to find the WiFi and connect automatically, then the websocket is set up.
One of them obviously doesn’t work with Android 9 (API28).
I don’t understand the error message, it is:

“Runtime Error
Failed resolution of [Lorg/apache/http/message/BasicNameValuePair”

Does anyone have any idea what this could be? Maybe it has nothing to do with this extension, but maybe someone had the same problem.

Regards
Sven


#27

Hi everybody. I did fight with this extension for a while and still couldn’t connect. In such case application crushed when I tried to send anything. The problem solution appeared to be trivial… WebSocket object method CreateConnection is described to accept port number as a nuumeric:
obraz
It didn’t work for me. But when I changed it to text, of course by mistake, it suddenly worked! ;-))) :
obraz
Maybe it helps somebody. My regards.


#28

I found the problem with my app crashing on start using a Android 9 device.
There was a change in Android 9 and a library was removed. This error can be avoided by adding the following line to the “application” section in the manifest file (starting with “<” and ending with “/>”, wich ist not displayable here)

uses-library android:name=“org.apache.http.legacy” android:required=“false”

Now the app is starting but I still do not get an websocket connection.
if I click the button wich than creates the websocket connection nothing happens.
I tested the app under Android 6 and 8 without any issues, but I cannot get it to work with Android 9.

The only difference I know between 8 and 9 wich could cause the problem is that Android 9 only accepts encrypted connections by default. This plugin only creates uncrypted connection (wich is absolutely ok in this case).
I tried another modification to the manifest file I found while investigating this issue.
I added the following line to allow uncrypted connections:

android:usesCleartextTraffic=“true”

Unfortunately it did not work. Any help is welcome!


#29

Try this or if you want to do it manually see post 33


#30

Hello ,
I kept on using WebSocket extension on my (small) NodeMcu projects , converting all of them to this much faster solution : now I’m trying to ‘push’ two esp8266 different project into one ESP32 , using the Dual Cores property , keeping the process actually separated , each under control ( also ) of my android WebSocket app…
How should I approach that , meaning is that extension capable to cope with more than one address (not at the same time , of course ) , or perhaps should I plan two distinct WS Clients ( and two IP addresses ) , each keeping a proprietary open ‘channel’ with its side of the application ?
Should the second be the correct approach , do the WS Clients allow simultaneous connections without interfering on each other ?
Thank you for the eventual suggestion .
Regards ,
Fabio R. - Rome - Italy


#31

if you are using esp32 it is better to work with mqtt and a broker + node red


#32

Thanks for replying … but that’s a totally new approach to me… what is the real advantage in using mqtt and node red ?
And what are the ‘cons’ with esp32 & websockets ?

Thanks again ,

Fabio R.


#33

http://mqtt.org/


#34

Hi Fabio!
Which library you used for ESP8266, that works?
I also want to make an ESP32 websocket server, but it is not working. At least with this extension. Or partly. I managed to make it work, but the ESP receive only every second message somehow.