How do I handle unexpected things such as weird data, corrupted data, unexpected data, or something going wrong in an event listener. WebSocket exposes a onmessage event listener. If it were to receive something unexpected, how is this to be dealt with? By throwing an exception, logging to console, silently ignoring it? If the event listener throws an exception, then
Tag: websocket
What is a simple way to use websockets in Node.js WITHOUT a library?
I want a simple socket connection, where the server should tell the client the total amount of connections (whenever a connection happens), and the client should update the DOM. I feel like socket.io or any other library is too full featured for such a simple reason. Any idea how to do this without libraries? Answer Node.js documentation shows a very
How to access formData in flask sent using websockets?Flask-SocketIO
How to access form data sent to Flask using web sockets? I receive invalid frame header in google chrome developer tools->console. Extract from my javascript code: How would I access, say ‘title’ field in my_form from flask ? request.form throws the same error “Invalid frame header” One more question, is it good to use web sockets for form submission and
disconnect client from socket.io id
I can connect specific player to specific room like: And documentation says that ‘you can use leave method to leave room’ like: But I just want any client to leave using io object instead of socket. I need something like: Is there any way to leave client from room using just socket id with io object? Answer As @tresdin mentioned,
Reactjs: how to share a websocket between components
I’m new to React and I’m having some issues regarding components structure and sharing a websocket between them. The app consists of categories and products. The initial data load will be done with an Ajax request and a websocket will be used keep data updated. My component hierarchy looks like this: CategoriesList Category ProductsList Product CategoriesList holds the state of
Client Socket.io disconnects and reconnects to websocket persistently
I am connected via Socket.io 1.3.4 (via websockets) to the NodeJS server and client socket.io fires up “disconnect” event 5-30 seconds. Every “disconnect”->”reconnecting”->”reconnect” iteration takes approx. 2 seconds. I am connected via cable to pretty stable network. Server is hosted on AWS. Sometimes I have bad Wi-Fi connection, but no “disconnect” event fire up at all. How can I debug
Socket.io not sending cookies in the handshake causing the request to stall
Let me explain my setup. I have multiple domain names that are all CNAME records for a main domain name, such as example.com. example.com -> serverIP company1.example.com -> example.com company2.example.com -> example.com I’m basically developing white labeled versions of our software, where the software simply detects the referrer and knows which logos and stylesheet assets to load. So that is
Java Server Socket transfer String to web socket
My goal is to set up a connection between a Java Server Socket and a browser (using web sockets). So far, the connection works, but my data streams do not. I would like to send a String from the server socket to the web socket. The problems are the input and output streams. The web socket sends “zustimmung” to the
Check if my website is open in another tab
I want to check with JavaScript if the user has already opened my website in another tab in their browser. It seems I cannot do that with pagevisibility… The only way I see is to use WebSocket based on a session cookie, and check if the client has more than one socket. But by this way, from current tab, I
Javascript websockets closing immediately after opening
The connection to the server is established and an alert is displayed for Connection open! However immediately afterwards the connection closes. The server does not call close and there seem to be no other errors in the console. This is happening in both chrome and firefox. I looked at a bunch of different similar examples on the web but to