Socket.IO

Socket.io chat app that can also send image and even file

妖精的绣舞 提交于 2021-02-05 20:30:29
问题 I've been interested in the Socket.io project recently and I wonder if there's easy way to send image or even other type of files without having to use other library. I'm not trying to upload the file to the server to store, I just want to broadcast it to those who are in the chat room at that moment. So the code should be minimal. However I'm really bad at encoding/decoding stuff, so some example code would be great. 回答1: I've adapted the official chat example of Socket.io and added

Electron: socket.io can receive but not emit

邮差的信 提交于 2021-02-05 20:19:10
问题 I'm creating an Electron application that uses Socket.io to communicate to a server application, but I'm experiencing a weird issue: whereas my Electron app successfully joins and receives messages from my server, it completely fails to emit anything. Client-side: const io = require('socket.io-client'); // ... var socket = io("http://localhost:8081"); socket.on('welcome', () => { console.log('welcome received'); // displayed socket.emit('test') }); socket.on('error', (e) => { console.log(e);

Electron: socket.io can receive but not emit

牧云@^-^@ 提交于 2021-02-05 20:18:37
问题 I'm creating an Electron application that uses Socket.io to communicate to a server application, but I'm experiencing a weird issue: whereas my Electron app successfully joins and receives messages from my server, it completely fails to emit anything. Client-side: const io = require('socket.io-client'); // ... var socket = io("http://localhost:8081"); socket.on('welcome', () => { console.log('welcome received'); // displayed socket.emit('test') }); socket.on('error', (e) => { console.log(e);

Electron: socket.io can receive but not emit

时间秒杀一切 提交于 2021-02-05 20:17:30
问题 I'm creating an Electron application that uses Socket.io to communicate to a server application, but I'm experiencing a weird issue: whereas my Electron app successfully joins and receives messages from my server, it completely fails to emit anything. Client-side: const io = require('socket.io-client'); // ... var socket = io("http://localhost:8081"); socket.on('welcome', () => { console.log('welcome received'); // displayed socket.emit('test') }); socket.on('error', (e) => { console.log(e);

Electron: socket.io can receive but not emit

烈酒焚心 提交于 2021-02-05 20:16:53
问题 I'm creating an Electron application that uses Socket.io to communicate to a server application, but I'm experiencing a weird issue: whereas my Electron app successfully joins and receives messages from my server, it completely fails to emit anything. Client-side: const io = require('socket.io-client'); // ... var socket = io("http://localhost:8081"); socket.on('welcome', () => { console.log('welcome received'); // displayed socket.emit('test') }); socket.on('error', (e) => { console.log(e);

Electron: socket.io can receive but not emit

£可爱£侵袭症+ 提交于 2021-02-05 20:16:30
问题 I'm creating an Electron application that uses Socket.io to communicate to a server application, but I'm experiencing a weird issue: whereas my Electron app successfully joins and receives messages from my server, it completely fails to emit anything. Client-side: const io = require('socket.io-client'); // ... var socket = io("http://localhost:8081"); socket.on('welcome', () => { console.log('welcome received'); // displayed socket.emit('test') }); socket.on('error', (e) => { console.log(e);

Electron: socket.io can receive but not emit

℡╲_俬逩灬. 提交于 2021-02-05 20:16:10
问题 I'm creating an Electron application that uses Socket.io to communicate to a server application, but I'm experiencing a weird issue: whereas my Electron app successfully joins and receives messages from my server, it completely fails to emit anything. Client-side: const io = require('socket.io-client'); // ... var socket = io("http://localhost:8081"); socket.on('welcome', () => { console.log('welcome received'); // displayed socket.emit('test') }); socket.on('error', (e) => { console.log(e);

node.js socket.io How to emit to a particular client?

醉酒当歌 提交于 2021-02-05 12:56:08
问题 I want to "emit" a message to a particular client which is selected based on another message received in a different client, How do I do this? I am thinking of joining each client to their own "room" and then broadcast. Is there a better way? 回答1: UPDATE for socket.io version 1.0 and above io.to(socketid).emit('message', 'whatever'); For older version: You can store each client in an object as a property. Then you can lookup the socket based on the message: var basket = {}; io.sockets.on(

My socket.io server start disconnecting clients randomly (for a “ping timeout” reason) when many clients are connected

Deadly 提交于 2021-02-05 09:28:56
问题 I'm building a website, where my client communicates with the server over web sockets. I'm using nodejs on the backend and hence, the famous socket.io library for web sockets communication. The Problem Everything works fine with 1 to ~ 40 clients, after that the server starts disconnecting clients randomly. at the start I thought it is a scaling problem, maybe memory or something like that. However, after an extensive debugging session, I noticed that the reason for disconnection is ping

My socket.io server start disconnecting clients randomly (for a “ping timeout” reason) when many clients are connected

拟墨画扇 提交于 2021-02-05 09:28:05
问题 I'm building a website, where my client communicates with the server over web sockets. I'm using nodejs on the backend and hence, the famous socket.io library for web sockets communication. The Problem Everything works fine with 1 to ~ 40 clients, after that the server starts disconnecting clients randomly. at the start I thought it is a scaling problem, maybe memory or something like that. However, after an extensive debugging session, I noticed that the reason for disconnection is ping