WebSocket Server #596
Replies: 11 comments
-
Posted at 2015-12-11 by @gfwilliams Ok, just changed so the following works:
All updated and documented here: http://www.espruino.com/ws |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-12-11 by tve Very nice! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-12-14 by @gfwilliams It uses 1924 vars (@16b/var) when doing this using ESP8266 with AT commands. BUT: even just connecting to the network (without any WebSockets) uses 1305 vars with ESP8266, so I'd say you're probably not that far off being able to make this work. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-06-23 by user65754 Hi. I tried that code, but i just recieve unreadyable data at the server.
The result in the web-ide is like that:
That should be always the same message...
What is wrong with the code? I run it with the pico VERSION 1v85 in combination with the esp8266. In addition the connection interrupt all the time. Is there an easy solution for a stable connection? I want to send a lot of data from client to the server. FullCode:
In Browserconsole (Chrome) i entered "ws.send(hallo welt)". Thanks. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-06-24 by @gfwilliams How stable is it when you're just getting webpages with normal HTTP? It could actually be a problem with your wiring... The ESP8266 draws quite a lot of power when it's going, and if the connections aren't good it can cause a lot of unreliablility, and I guess potentially the corruption you are seeing. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-06-24 by @gfwilliams No, you're right - I just tested here and got the same. I think the unreliability could still be wiring - sometimes adding a capacitor across ESP8266's power helps. The corruption seems to be related to Espruino getting split packets from the ESP8266. It gets the start of the data packet, but not the rest - what you're seeing is the 4 'mask' bytes repeated over and over. I'll see what I can do to fix that now. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-06-24 by @gfwilliams Ok, try now - the corruption should now be gone at least. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-06-25 by user65754 Next post... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-06-25 by user65754 Great to hear from you. Thank you for your response! Now it seems to work 95% :) Some of my tests:
The named lines (1,2) should be also the same message as before. My conclusion is, that i still get that "unreadable" data, if i wait a little bit. Start the WebSocket and send a Message -> OK So always if i wait a little bit it seems that the next data package can't processed successfully. If i wait for 5-10 Minutes and try to send a message from Chrome:
I would be really happy if you could check that again :) Thank you! Edit: I looked at the ws.js file. Why you don't allow to send data bigger then 125 character? How can i send more than 125? I need to send more than 300 characters. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-06-26 by Wilberforce The current implementation is limited to 125 chars. To use larger the module would be need to be implemented to split the data over multiple packets which complicates things quite a bit. Do you have a sample of the data you want to send? There might be a way of reducing the amount of data, especially if there are large text descriptors in the data. You can also store the data in a struct, and the convert that to json to send. The json can be self describing, so you could split your message into chunks that are under the 125 byte limitation. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2016-06-26 by user65754 I try to stream video data to the server to control 100 ws2812 leds. But i get no stable connection. Always if i send between 25 and 60 messages i get:
Would be really good so solve this problem first ;) If i couldn't get a reliable connection, i can't use that websocket implementation... Please have a look at it. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2015-12-11 by @gfwilliams
Hi,
Just to say that the latest builds of Espruino now support WebSocket server in JS. Not only that, but mixed WebSocket and HTTP server!.
For instance:
I had to tweak the WebSocket library a bit, but it hopefully at some point the code above can mostly be rolled into the library and you'll be able to do something like:
Beta Was this translation helpful? Give feedback.
All reactions