websocket example connection error #1295
Replies: 26 comments
-
Posted at 2018-05-09 by J{a}SON i've tested the server with versions of npm ws 5, 4, 3, and 2. all give the same error about RSV1 must be clear, after connecting from the client. i have not tested the client on espruino wifi with versions older than 1v97. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-09 by @gfwilliams Thanks for letting me know. Sorry about this - it seems to be a bug introduced in a recent pull request to Espruino. I'll try and get it fixed as soon as possible If you try firmware 1v96 (or any commit before 46e4bc69d73631b63f62b11febb4f2c07ec1acf3) then that should work. You can follow the fix here if you're interested: espruino/Espruino#1405 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-09 by J{a}SON thanks @gfwilliams. conversely, when trying to run a websocket server on the espruino, and connect from a node.js client, i get the error: Error: Server sent a subprotocol but none was requested and the client disconnects. i will try 1v96 today. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-09 by J{a}SON i have confirmed that 1v96 works with espruino as the websocket client. i am still receiving an error when espruino is the server, using the example code, and i use this code in node.js Error: Server sent a subprotocol but none was requested
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-09 by @gfwilliams And the error comes from Node.js? Strange thing is it'd seem that you are requesting a subprotocol of |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-09 by J{a}SON This may be user error, as the espruino websocket server example works when the client is a web browser. when trying to get the client to be a node.js app, i'm having issues. this gives the same error from node.js. i can see the blue light flash on the espruino when i run the client, but there is no output in the espruino repl. is there an example for espruino websocket server, and node.js client?
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-09 by J{a}SON changing the connection to mirror the browser client connection in the embedded web page worked
i didn't see that 'protocolOne' parameter documented anywhere. it works, so i'll move on for now. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-10 by @gfwilliams Just to add that @opichals has just fixed this, so any new firmware from http://www.espruino.com/binaries/travis/master/ (or 1v98 and later) will have this fixed. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-10 by J{a}SON there were other regressions with 1v97.60, e.g. the getPage() example did not return a page. reverting to 1v97 or 1v96 does work. i'll wait for an official release to move forward from 1v96 for now. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-10 by J{a}SON i tried 1v97.62 as well. this code does not return a page to the repl anymore
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-10 by J{a}SON also with 1v97.62 i am not able to complete a websocket connection with espruino as the server and a webpage as the client. it stays in the connecting state. same code is working in 1v96 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-11 by @gfwilliams Thanks - I think @opichals is looking into this now :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-12 by opichals I tried the getPage() and it did work for me when the URL is correct. Cutting & pasting from the forum's example however mangled the URL for me so I got a 'Not found' error. @j{a}SON could you try this and post the whole console result?
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-12 by opichals Submitted a fix PR |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-12 by J{a}SON which build are you looking at? the larger remaining problem is the espruino not working as a websocket server, as documented in the github issues espruino/Espruino#1405. i'll test again if you let me know which build to look at. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-12 by opichals @j{a}SON I would wait for the espruino/Espruino#1415 to get merged and then grab the master build for further tests. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-14 by @gfwilliams Just done :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-14 by J{a}SON ok, this is working now with espruino as the ws client, and ws server. getPage() is working as well. i do have an additional question: when espruino is the ws client, and i send a message from the node.js server, it shows up as a rawData event as well as a message event. is this expected?
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-14 by Wilberforce Yes. Listen to one event or the other... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-14 by @gfwilliams Just to add - 'rawData' is basically just a debugging aid for the websocket implementation. 99.9% of the time you'd want to use the message event :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-05-14 by J{a}SON glad we got this sorted out. now i can move on to programming ble on my pucks :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-03-13 by Wilberforce I've manager to reproduce one of these issues using a current build on linux. vue native sockets in chrome browser -> Backend Espruino WS server. If protocol is specified, then all is well:
However, if this is defaulted, ws.js on the espruino sends as a header:
this test seems to be failing:
in the constructor we have: So it seems this is setting What is the cleanest way to fix?
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-03-13 by @gfwilliams Ahh - that's frustrating. Thanks for checking up - I believe I may have fixed this for the Espruino as client case, but not Espruino as server. I think the code you pointed to is for the client, and is actually working. What was needed was to add that same check for the server case. I've just done it here: espruino/EspruinoDocs@74d779d It's not on the website yet, but you can |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-03-13 by Wilberforce Thanks for updating! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-03-14 by Wilberforce I can confirm that this is working now. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2019-03-14 by @gfwilliams Great - thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2018-05-08 by J{a}SON
when attempting to follow the websocket client example at http://www.espruino.com/ws, i get errors on the server (running node.js on a windows10 laptop) as:
RangeError: Invalid WebSocket frame: RSV1 must be clear
When I modify the code to use the npm ws client on the laptop, it works fine.
server:
node 8.9.4,
"dependencies": {
"express": "^4.16.3",
"http": "0.0.0",
"url": "^0.11.0",
"ws": "^5.1.1"
}
espruino wifi client:
1v97
output on the repl is
Beta Was this translation helpful? Give feedback.
All reactions