-
Notifications
You must be signed in to change notification settings - Fork 12
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
Add websocket endpoint #23
Comments
Hi @patrickelectric, Zenoh actually has a WebSocket transport: https://github.com/eclipse-zenoh/zenoh/tree/master/io/zenoh-links/zenoh-link-ws In order to use it you need to start a router with the WebSocket locator configured: e.g., Furthermore, we are in the process of develop a JavaScript/TypeScript API that will leverage the WebSocket transport to communicate to Zenoh routers and peers and thus allow to fetch data in realtime. |
Hi @gabrik, and thanks for the info. Now I have more questions 😄 How can I use this websocket ? If I let it open I do not receive any messages from it as well, I'm using the following code: let socket = new WebSocket("ws://0.0.0.0:8002");
socket.onopen = function (e) {
console.log("[open] Connection established");
console.log("Sending to server");
// Help, I need somebody, help, not just anybody!
// socket.send("/**");
};
socket.onmessage = function (event) {
console.log(`[message] Data received from server: ${JSON.stringify(event)}`);
};
socket.onclose = function (event) {
if (event.wasClean) {
console.log(
`[close] Connection closed cleanly, code=${event.code} reason=${event.reason}`
);
return;
}
console.error("[close] Connection died");
};
socket.onerror = function (error) {
console.error(`[error] ${JSON.stringify(error)}`);
};
setTimeout(function () {
socket.close();
console.log("Closing the WebSocket connection after 60 seconds");
}, 60000); |
The WebSocket Transport for Zenoh expects the Zenoh protocol to be used as the payload of the WebSocket. The WebSocket transport can be easily used by the Zenoh examples, but so far not from JS (unless you implement the whole protocol stack, or wait for an initial version of our JS API to be available). |
Thanks for the update @gabrik, where is this being worked on at the moment ? I may help on that. |
This is being worked here: |
Describe the feature
It would be nice for web services to subscribe to topics using websocket and fetching data in real time
The text was updated successfully, but these errors were encountered: