-
Notifications
You must be signed in to change notification settings - Fork 565
Websockets compatibility/Implementation HTML5 vs Socket.io #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
socket.io is a protocol on top of websockts. the protocol basics are here: |
Thanks, I will take a look onto this one. |
i have done the other part connecting the ESP/AVR to a socket.io server (nodejs). |
Oh by the way I reverted to HTML5 browser integrated websocket and I'm able to talk with your ArduinoWebSocket compiled into ESP8266 ;-) |
looks nice, is it bootstrap? |
Yes bootstrap + some goodies such
all framework minified+gz to be positionned in spiffs FS ;-) |
Hey, could you guys share some of your socket.io for Arduino code? |
i plan to create 2 classes for server + client out of it and add it to this repo, |
@Vitorbnc
and the client side I'm using ReconnectingWebSocket lib (to allow automatic re connection) but it's not mandatory window.onload = function() {
// open a web socket
socksrv = 'ws://'+location.hostname+':8081';
ws = new ReconnectingWebSocket(socksrv);
// When Web Socket is connected
ws.onopen = function(evt) {
console.log( 'ws reconnect');
$('#mdl_wait').modal('hide');
$('#connect').text('connected').removeClass('label-danger').addClass('label-success');
elapsed=0;
clearInterval(el_timer);
refreshPage();
};
// When websocket message
ws.onmessage = function (evt) {
var obj = eval( "(" + evt.data + ")" );
var msg = obj.message;
var data = obj.data;
appendLog('ws msg:'+msg+' => '+ JSON.stringify(data) );
if (msg=='sensors') refreshSensors(data);
if (msg=='system') refreshSystem(data);
if (msg=='log') appendLog(data);
};
// When websocket is closed.
ws.onclose = function(code, reason) {
$('#connect').text('disconnected').removeClass('label-success').addClass('label-danger');
};
// When Web Socket error
ws.onerror = function(evt) {
appendLog( 'ws error');
};
} |
@Links2004 |
@hallard async one for testing: |
@Links2004 |
@hallard thanks for sharing code! I'd like to know what exactly the async lib does too. |
the sync version do handle all stuff in the arduino loop (the loop call of the lib) and one client after a other. the async version is event bases, but keep in mind the webSocketEvent callback will work like an interrupt then so no delay in there. |
@Links2004 But in my main loop, every seconds (example) I need to check connected clients (browser), how can I handle this? IE looping thru all client connected, check if they need data and send them ? |
I was trying to test WebSocketClient example with async, but I'm getting:
|
you need latest git of the ESP core |
Got the last version of ESP. Now everything is fine with the async version. Do I need a special sketch to test it properly? |
the normal examples will work, only the loop call is not needed any more. |
@hallard |
Hey, just a doubt. What CPU and Flash frequency do you use? Is it safe to use 160MHz for CPU and 80MHz for Flash? |
@Vitorbnc |
its based on the flash you have some can handle 80Mhz fine some not, |
@Links2004 |
Really depends on Board quality, good post here |
you can get the Ip for every client that is connected, |
Excellent, so something like that will work ?
|
yes |
;-) thanks |
Can I have both client and server? I'd like client to talk to Nodejs and server to talk to browsers directly. |
yes you can have server + client a the same time. |
@hallard , have you upgrade your sensor live data examples by markus library? also have you any plan to check video stream feature of Markus websocket library ? |
I searched halliard's github and blog but couldn't find his screenshots codes. Anyone know where it is? https://cloud.githubusercontent.com/assets/2471931/12455916/dbb6efa2-bf9d-11e5-8e56-6434a2698d99.png |
@kiralikbeyin About the code you're talking about, it's not currently released but will be soon Charles |
Hi Charles Thank you for reply. Your repos are really awesome. I also wrote to your blog; I will play with this code https://github.com/koffienl/ESPimatic until you I am looking forward. Thanks. Kiralik 22 Mayıs 2016 Pazar tarihinde, Charles [email protected] yazdı:
|
You're welcome, by the way, nice piece of code ESPimatic ;-) |
@hallard |
this is a best solution . in order to work with socket.io client library, you need a nodejs server with socket.io https://github.com/dtoki/Socket.io-Esp-client |
Hi Markus,
I developed my test environment with my html/javascript and nodejs server to be easier to test my html/js code before putting it into ESP8266. I used websocket socket.io library. All on my environment is working fine, but now I'm trying to put all thing into ESP and here is my problem :
although your sample code html/js are working fine with ESP8266, as soon as I'm trying to connect to ESP8266 with socket.io it does not work or even connect.
I was thinking websockets was "standard" but it seems libraries may have different implementation.
At startup I wanted to use the HTML5 one on client side (the native one in browser, same as your examples) but for the same reason I didn't not succeed to connect with this one from my client broswer to my nodejs server running socket.io
I love socket.io because it implements all disconnect/reconnect mechanism (and other) but Im' afraid may be I need to use the basic HTML5 one to get it working with you lib ?
Any hints or explanation would be useful for my understanding because I'm lost on websocket jungle.
Thanks for your help
The text was updated successfully, but these errors were encountered: