I am trying to connect to a webSocket server on port 2998 using the c# package websocket-sharp.
On the client side I am using the following code (written in c#):
WebSocket webSocket = new WebSocket("ws://localhost:2998");
webSocket.Connect();
webSocket.Send("test");
On the server side i am using node.js running the following code (written in typescript):
import { WebSocketServer } from 'ws';
const wss = new WebSocketServer({
port: 2998,
});
wss.on("connection", (ws) => {
console.log("connected")
ws.on('error', console.error);
ws.on('message', function message(data) {
console.log('received: %s', data);
});
ws.send('something');
})
I expected to see connected
and test
logged in the terminal on the server side, but nothing is being logged. If you can provide me with a solution or help of any kind it would be greatly appreciated.