Hello! Couldn’t find in the official docs how to find a websocket port to connect to Volumio server.
Using the following code in Rust which fails to connect:
use rust_socketio::{ClientBuilder, Payload, RawClient};
use serde_json::json;
use std::time::Duration;
fn main() {
let callback = |payload: Payload, socket: RawClient| {
match payload {
Payload::String(str) => println!("Received: {}", str),
Payload::Binary(bin_data) => println!("Received bytes: {:#?}", bin_data),
}
};
// Connect to the server
let socket = ClientBuilder::new("http://192.168.1.144:3000")
.namespace("system")
.on("message", callback)
.connect()
.expect("Connection failed");
// Emit a "shutdown" command to the server
let message = json!({"namespace": "system", "method": "shutdown"});
socket.emit("shutdown", message).expect("Server unreachable");
println!("Shutdown command sent. Waiting for a response.");
// Wait for a short period to receive messages
std::thread::sleep(Duration::from_secs(5));
socket.disconnect().expect("Disconnect failed");
println!("Done.");
}