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
// establish a connection to the server
const socket = new WebSocket('ws://localhost:3000');
console.log(socket);
socket.onopen = () => {
// now we are connected
console.log('connected');
socket.send('some text'); // send some text to server
};
socket.onmessage = (message) => {
// here we got something sent from the server
console.log('closed');
};
socket.onclose = () => {
console.log('closed');
};
Output: In chrome console
client.js:2 WebSocket connection to 'ws://localhost:3000/' failed:
closed
The text was updated successfully, but these errors were encountered:
jatin510
changed the title
not able to connect to make websocket connectin.
not able to connect to make websocket connection.
Jul 8, 2021
Hi !
I ran the code with
yarn start:dev
command.I can connect to the
http://localhost:3000
.But when I tried connecting to the ws server. I can't connect to it.
What I tried.
This is my index.html file
client.js
Output: In chrome console
The text was updated successfully, but these errors were encountered: