You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Trying out the web example, there are several issues preventing it from working properly with the native browser WebSocket that I've had to work around or am in the process of working around.
However, ping() is not sufficient as it's not a true websocket ping message. I still receive the error:
Roon API Connection to 192.168.1.10:9330 closed due to missed heartbeat
And the connection genuinely closes.
However, with those polyfills, the web app does work for a few seconds! Better than nothing.
I've explored how to get the ping() message working from the web, but there doesn't seem to be a reasonable way to send a message with the proper opcode directly from the native WebSocket. It's below the abstraction layer of the browser websocket library, and you don't get to break down and send the right message type for a true ping, whereas the Node library does offer just that.
You can't use the node library in the browser, that's the first thing I tried.
I'm not sure how to get around this ping piece exactly. Ideally, the Roon API itself is a little more open to how native browser WebSocket works (it sends its own ping packets automatically, afaik, on a slightly slower rate than Roon expects it seems).
My next workaround is probably to just do the Roon API connection on a backend instead of in the browser, and message pass to the frontend, but I'd rather not go that direction if it can be helped.
Steps I see:
Fix implementation of node-roon-api to be compatible with the native WebSocket browser API, and avoid using methods not available in the browser.
Bigger ask but the only proper solution I see -- adjust the timing or implementation of the Roon API service to be friendly with browser WebSocket connections. Will require inspecting what browsers actually do for keepalive and adjusting to fit; or alternatively being open to recieving a standard websocket message with a special payload as an "alternative ping" that browsers can send and considering it the same thing.
I could potentially help with the first, but likely not the second! Thanks.
The text was updated successfully, but these errors were encountered:
trisweb
added a commit
to trisweb/roon-extension-web-testapp
that referenced
this issue
Mar 5, 2023
* Add polyfills for the native WebSocket browser implementation to be compatible with nodejs ws methods that the Roon API library uses
* Add periodic reconnect (every 8 seconds) to get around disconnect every 10 seconds due to inability of browser WebSocket to send a Ping often enough. Unfortunately there is not a solution to this without changing the Roon API behavior.
Works fine with these changes and is actually a great app for Roon; however the view flashes every 8 seconds.
See issue RoonLabs/node-roon-api#34 for core issue with roon js API using non-native WebSocket methods. Though, it is billed as a "node roon API" so not sure if that's in scope.
Trying out the web example, there are several issues preventing it from working properly with the native browser WebSocket that I've had to work around or am in the process of working around.
https://github.com/roonlabs/roon-extension-web-testapp
The following methods are used by the Roon library, however are not available in native browser WebSocket:
on()
,ping()
, andterminate()
The following polyfills within the example app are working reasonably to get the app running:
However,
ping()
is not sufficient as it's not a true websocket ping message. I still receive the error:And the connection genuinely closes.
However, with those polyfills, the web app does work for a few seconds! Better than nothing.
I've explored how to get the ping() message working from the web, but there doesn't seem to be a reasonable way to send a message with the proper opcode directly from the native WebSocket. It's below the abstraction layer of the browser websocket library, and you don't get to break down and send the right message type for a true ping, whereas the Node library does offer just that.
You can't use the node library in the browser, that's the first thing I tried.
I'm not sure how to get around this ping piece exactly. Ideally, the Roon API itself is a little more open to how native browser WebSocket works (it sends its own ping packets automatically, afaik, on a slightly slower rate than Roon expects it seems).
My next workaround is probably to just do the Roon API connection on a backend instead of in the browser, and message pass to the frontend, but I'd rather not go that direction if it can be helped.
Steps I see:
I could potentially help with the first, but likely not the second! Thanks.
The text was updated successfully, but these errors were encountered: