I have rust TCP server code:
fn main() {
let mut server: TcpListener = TcpListener::bind("0.0.0.0:8080")
.expect("[SERVER]: Failed to bind");
let mut handler: Handler = Handler::new();
loop {
let mut Client = server.accept().unwrap();
//Handler basically tests if client has send a message and prints that message out
//the problem is, the client "Connects" server-side, but the websocket client say's it is "connecting"
handler.newClient(Client.0);
}
}
And I have websocket client code that connects to the server (from the browser):
let ws = new WebSocket("ws://0.0.0.0:8080");
ws.onopen = function(event) {
ws.send("Hello, world!");
}
Anytime a client connects the server will create a new thread for it and log "Client connected" and also logs anything the client sends. When I execute the client script the server Prints out "Client connected" as expected. But it never gets "Hello, world!", which the client is supposed to send. I am suspecting its because you have to make a actual websocket server. Is there any way to connect a websocket to a non-websocket/socket.io server? Or at least use a different way to connect to a non socket.io/websocket server with js in the browser? Thanks!