Questions tagged [socket.io]

Socket.IO revolutionizes the landscape of real-time applications by enabling seamless functionality across all web browsers and mobile devices, seamlessly merging various transport mechanisms. It provides robust support for diverse transports including WebSockets, Flash sockets, long polling, and others. Additionally, Socket.IO diligently adapts to any transport failures, automatically resorting to suitable alternatives.

Shortcut Express Lane and Socket io

Recently, I configured my socket io connection to send information to the frontend and receive responses from the client. The data is successfully saved as well. However, it seems unnecessary to initialize socket io in the server.js file when its function ...

Setting up Socket.io results in numerous transport polling GET requests being initiated

I have set up an express.js server-side and followed the socket.io guide. However, I am facing issues with the socket connection not being successful, and there seems to be a high number of unexpected GET requests like this: https://i.stack.imgur.com/GDGg ...

Pass on Redis Pub/Sub messages to a designated client in socket.io through an Express server

Currently, in my express server setup, I am utilizing socket.io and Redis pubsub. The process involves the server subscribing to a Redis message channel and then forwarding any incoming Redis messages to a specific WebSocket client whenever a new message i ...

Why is Socket.io functioning on localhost but fails to work once deployed to Heroku?

Sharing my socket server code: const io = require("socket.io")(8080, { cors: { // origin: "http://localhost:3000", origin: "https://mern-bubble.herokuapp.com", }, }); This is the client-side implementation: useEf ...

Socket.io is unable to function properly when when using the on event ("connection")

I am trying to incorporate socket-io into my project and have set it up on both the server (node-js) and the client (react). However, I am encountering issues as it doesn't seem to work properly. In the server console, I am unable to see the message user c ...

A step-by-step guide on creating a live crud application with vuex and socketio

I am struggling to achieve a realtime crud operation using vuex, node, express, and socketio with the current syntax provided. Here is the code snippet: Server index.js const server = app.listen('3000',() => { console.log('<--- ...

Encountered an issue when trying to proxy to the Node.js/Express Socket.IO server with Next.js

I'm currently facing an issue with establishing a connection between my Next.js/React client and my Express/Socket.io backend (not running as a Next.js custom server). When I attempt to proxy regular HTTP requests using rewrites in the next.config.js ...

The Battle of node.js Modules: Comparing socket.io and express.static

The server.js file I am currently running is set up as follows: module.exports = server; var express = require('express'); var fs = require('fs'); var server = express.createServer(); var port = 58000; server.listen(port); var io = require('socket ...

Is it possible to horizontally scale socket connections using a combination of node.js, socket.io, and redis in an

I am diving into the world of node.js for the first time and seeking some guidance: Here are the programs I have installed on my server: node.js v0.11.3-pre express v3.3.4 socket.io v0.9.14 connect-redis v1.4.5 Redis server v=2.6.14 redis-cli 2.6.14 To ...

Forwarding AngularJS events using socket.io with the use of deferred promises

I recently started using the Angular library angular-socket-io for my project. However, I encountered a challenge where I needed to implement authentication within the app before initializing the socket.io interface. To address this issue, I found and impl ...

There seems to be an issue with the connection between socket.io and the server

Recently, I encountered an issue while hosting my application on OpenShift with a custom domain. The problem arose when socket.io failed to download the client-side script, leading me to resort to using a CDN instead. However, this workaround has caused an ...

What are the steps to fix a timeout error with React.js and socket.io acknowledgements?

My setup includes a Node.js server and a React.js client application. Data is exchanged between them using socket.io, but I'm running into an issue with implementing acknowledgment. Whenever I try to implement acknowledgment, I receive a timeout error: Err ...

Using Socket.io with Node.js

Currently, I am incorporating socket.io within a NodeJS application. The socket.io page can be accessed at localhost:8081/socket.io/. However, my goal is to have it located at localhost:8081/hola/socket.io/. Is this achievable? var express = require("e ...

Testing the integration of socket.io with Angular through unit tests

Currently, I am in the process of unit testing an angular service within my application that is responsible for creating a socket.io client. The structure of my service can be seen below: export class SocketService { private name: string; private host ...

Hapi.js - A guide on effectively passing connections to plugins

Incorporating Socket.io into my project has been a key component. I have developed a plugin specifically for managing socket connections... await server.register(socket_connections); This code snippet illustrates the structure of the socket_connections p ...

What are the potential drawbacks of relying heavily on socket.io for handling most requests versus using it primarily for pushing data to clients?

Is it advisable to switch AJAX routes (called with $.Ajax in jquery) like: GET /animals GET /animals/[id] POST /animals To socket.io events (event bound on client and server for client response): emit("animals:read") emit("animals:read", {id:asdasd}) ...

The collaboration of React hooks, typescript, mongoose, express, and socket.io in perfect harmony

I am currently working on setting up a frontend React app to communicate with a NodeJS Express API using socket.io import React, { useEffect, useState } from "react"; import io from "socket.io-client"; const socket = io("http://lo ...

The Socket.io Chat application is indicating a memory leak with the EventEmitter, detecting 11 listeners that have been added. To resolve this issue

My private chat application is built using socket.io, node.js, and MySQL. However, I encountered an error when trying to use socket.on('example', function(data){...});. The error code thrown is related to a possible EventEmitter memory leak with 11 listene ...

The Mystery of Socket.io Random Disconnects (version 1.0.6)

Currently, I am utilizing the most recent version of socket.io (1.0.6) to develop an online multiplayer game using Phaser and Node. One issue that has arisen is that after the clients connect, they will sporadically disconnect without any specific pattern. ...

Should I use express with NodeJS and socket.io?

Just a quick question. I'm currently in the process of creating an online browser game with phaser and socket.io. I know I'll be using socket.io quite a bit, but what about express? Once I start the server, what other tasks will I need to complet ...

Working with AngularJS's $q promise and socket.io

I am interested in creating an angularJS promise that can work seamlessly with socket.io. Currently, I have a callback function set up to handle the response like this: function request(event, data, callback) { socket.emit(event, data); socket.on( ...

Angular in conjunction with socket.io does not immediately show messages on screen

I am currently working on developing an instant messaging app (chat) using socket.io and Angular. I have two main files: index.html and index.js as shown below. The chat functionality is working well, but I am facing an issue where the messages do not appe ...

NodeJS Socket not transmitting file after connection with client

Having scoured the depths of various resources, including SO and Google, I have hit a roadblock. I am struggling to understand why the socket is failing to capture the uploaded file via the form; it simply stops after connecting. When I check the console, ...

Dual Networked Socket.IO Connection

I have set up a node.js server with an angular.js frontent and I am facing a problem with Socket.IO connections. The issue arises when double Socket.IO connections open, causing my page to hang. var self = this; self.app = express(); self.http = http.Ser ...

I'm having trouble getting Socket.io to function properly with my Node/Express application

Using openshift with express, I have been experiencing difficulties configuring socket.io. No matter what adjustments I make, it seems to disrupt my application. What could be the issue? Interestingly, when I disable the sections related to socket.io, the ...

Tips for limiting the frequency of Angular provider loading instances

I have created a provider (I tried with a controller as well, but got the same results). Here is my code: .provider('socketio', function() { this.socket = io.connect("//localhost); console.log("LISTENING..."); this.$get = function() { [...] } ...

Looking to implement Socket.io in a Next.js and Node.js application to send a targeted socket emit to a particular user

I've been working on this issue and have tried various methods, but haven't had any luck so far. Despite reading through a lot of documentation and posts, I can't seem to figure it out. What I need is for a message sent to a specific user (usuarioActual.u ...

How to access socket.io instance in Node.js Express route files

One of my goals is to send data to clients connected to a socket.io server directly from my express routes files. In my app.js, the structure is as follows : var express = require('express'); var app = express(); //routes require('./routes/test')(app); ...

Inconsistent 404 Error when Making Socket.io Ajax Requests

My Node server is responsible for managing user sessions, chatrooms, messaging, web scraping, and other tasks. Sometimes, when attempting to send messages from the website to the Node server, I encounter a 404 error in the response. This issue occurs rare ...

Why is the function app.get('/') not triggering? The problem seems to be related to cookies and user authentication

Need help with app.get('/') not being called I am working on implementing cookies to allow multiple users to be logged in simultaneously. Currently, users can log in successfully. However, upon refreshing the page, all users get logged in as the ...

Is there a way to retrieve the current logged in user when working with socket.io?

When it comes to retrieving the logged in user using passport.js in most of my routes, it's a breeze - just use req.user.username. However, I've encountered an issue with a page that relies solely on websockets. How can I determine the username of the logg ...

Building interactive chat "hubs" with Node, Express, Heroku, and Socket.io

As I've been working on my app for a while now, scalability issues have started to arise. With my limited experience in Node and Heroku, I'm reaching out for some guidance. Initially, I followed this tutorial to set up my node service, essentially creatin ...

My goal is to transfer information from the client-side to the server-side upon the user disconnecting from a socket.io connection using Node.js

Is there a way to transmit data from the client side to the server side when a user disconnects from a socket.io connection in Node.js? I attempted creating a new event and calling it within the 'disconnect' event, but it seems impossible since the conne ...

Save the socket.id from Socket IO into the Express session

Currently, I am working on a web application that utilizes Angular and Express. To handle database updates, I have implemented a REST API and incorporated SocketIO for real-time client updates. I have managed to track a list of active socket IDs for each ...

Unable to establish a connection between Socket.io and Express.js framework

Struggling to establish a connection with socket io. app.js file var express = require('express'); var path = require('path'); var mongoose = require('mongoose'); var cookieParser = require('cookie-parser'); var in ...

Socketio: Issue: Isolated surrogate U+D83D is not a valid scalar value

I've been experiencing frequent crashes with my node.js server recently, all due to a recurring socket.io error. It seems that the client may be sending invalid UTF strings, causing an error in the utf8.js file. I'm getting frustrated with the co ...

The node experiences a crash when the redis-server goes offline

Struggling with a persistent issue here. Despite reading numerous documents and posts from others on the same topic, I can't seem to find a solution to prevent this problem. I am intentionally shutting down the redis server to avoid potential disaster ...

socket.io / settings when establishing a connection

I'm facing an issue in my node.js / Express.js app where I need to pass parameters with the socket.io connection (saw a solution in another post). On the client side, here is a snippet of my code: edit var socket = io.connect('/image/change&ap ...

Timeout occurs in method calls when using socket.io and socket.io-redis adapter together

After recently transitioning from Socket.io 2.x to 3.0.3 and integrating it with [email protected], I encountered an issue. Following the instructions provided in the original migration documentation, I attempted to retrieve a list of all open socket ...

Socket IO issue: CORS policy is blocking access to XMLHttpRequest

My application recently encountered an error. "Access to XMLHttpRequest at '' from origin '' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource." When connecting to socket.io, I haven't ...

Employing socket.io for transmitting data to a particular view or ID

Currently, I am developing a web application that utilizes NodeJS, Express, and MongoDB. Within this application, there is a view accessible to all users which displays different images based on the selection made by the user (no login required). This spec ...

Using Socket.io to securely store user authentication is the most effective method

I am currently facing some challenges with authenticating users in socket.io for my chat application. I am storing all users in an array using the following structure: let sockets = []; sockets[userdbId] = socket.id However, there are a few issues that I ...

Get rid of the port in Socket.IO and alter the directory

While utilizing Apache on Ubuntu 15.04, I am attempting to eliminate port 3000 from the URL and modify the path to http://example.com/{app}/socket.io... By employing ProxyPass and ProxyPassReverse, I have successfully removed the port from the URL and adj ...

Tips on integrating Socket.io with Express?

I've written the Express code in my server JS file: app.post('/confirm', function (req, res) { // Currently struggling to send a socket using emit() }); Here is the Socket.io code I have: io.on('connection', function (client) { // Implementing all ...

Dynamic content with Socket.io in Node.js

I am attempting to create a scenario where nodejs triggers an event in an irc chat that causes a html page (Running on *:3000) to execute some JavaScript. However, I am facing an issue where the showDiv(); function is not being executed as expected. Curre ...

One-way communication between two clients using Socket.io

While working on a basic socket.io application using React and Express, I've encountered an issue where two clients are facing difficulties in sending data to each other. For instance: Player 1 connects to the server followed by Player 2. Player 1 ...

Error encountered while establishing connection with Flutter, Node.js, and Socket.io

I'm in the process of building a multiplayer TicTacToe game using Flutter and Node.js with Socket.io integration. Here is the code: Flutter late io.Socket socket; final String url = 'http://localhost:5000'; @override void initState() { super ...

CommunicationsError on Socket.io server

I am currently experiencing an issue with a Socket.io server that is running through an Express.js server with Next.js. The server is sending errors without any client being connected. However, clients can still connect from the browser without any proble ...

"Unfortunately, SockitIO is repeatedly running into issues with being blocked by

I keep encountering an error in my application (using Node.js as API) and Angular 8 as frontend. The error message says: Access to XMLHttpRequest at 'http://localhost:3000/socket.io/?EIO=3&transport=polling&t=NQJpoTm' from origin 'ht ...

Connecting socket.io to a Vue.js single page application using Javascript

I am new to Vue.js, Socket.io, and Node.js. Recently, I developed a single-page application that allows communication between a Node.js server running on a Raspberry Pi and a Siemens S7-1500 PLC connected via Ethernet. The Raspberry Pi acts as a WiFi acces ...

transmitting a JSON object along with an audio file to a designated socketId through the Socket.io WebSocket connection in my application

I am currently in the process of implementing a chat feature for my app and I'm contemplating the most effective approach to achieve this. Here is the concept I have in mind: The user will select who they want to communicate with, then record an aud ...

An exemplary chat application that utilizes sessions for user authentication in a node.js environment with socket.io and express

Is there an example available that stores sessions and uses those sessions for all opened windows, allowing one user to connect to a specific room only once? This application will treat phpsessions as node.js sessions, but I am struggling to restrict acce ...

The function socket.on(..) is not being triggered

Currently, I am in the process of developing a straightforward website to showcase socket communication and chat capabilities. The server side is coded using Python Flask app, while the client-side utilizes JavaScript. Below is an excerpt from the server c ...

Can an ejs template be displayed without the need to refresh the page?

I'm currently developing a game server that involves players entering a game room and getting paired with another player. One feature I would like to implement is displaying the game board without having to reload the page in order to avoid reinitiali ...

You cannot assign void to a parameter expecting a function with no return value

I have been working on an angular application that was initially developed in Angular 2, then upgraded to versions 7 and 9, and now I'm attempting to migrate it to Angular 11. There is a function in my code that fetches the notification count for the ...

Header frame is not valid

I have been working on developing a real-time application using NodeJS as my server and Socket.IO to enable live updates. However, I encountered an error message that reads: WebSocket connection to 'wss://localhost:1234/socket.io/?EIO=3&transport=we ...

Can Socket.io be connected only when a user logs in?

Exploring the fundamentals of Socket.io and aiming to establish a connection ONLY when a user logs in. The official documentation doesn't provide clear guidance on this specific implementation. Utilizing JWT for authentication and Node.js for server-side p ...

Redux toolkit does not synchronize with Socket.io

Imagine a scenario where you have developed a chat app similar to WhatsApp Web. In this app, the chat section displays all chats on the left and in the middle. Upon user login, the first contact is saved in the Redux store as selectedChatUser. All the cha ...

"Utilizing SocketIO in NodeJS to create a unique game mode emission

As a new socketIO user, I am working on a website with 2 game modes. Initially, my plan was to create separate scripts for each mode, but now I am considering consolidating everything into one script. Currently, my script emits data to all connected users, ...

Having trouble reaching the io object in session.socket.io

I have integrated session.socket.io into my application. o = require('socket.io').listen(tmpServer), appCookieParser = express.cookieParser(settings.cookie.secret), appRedisStore = new RedisStore(), sessionIO = new SessionSockets(io, appRedisSto ...

Broadcast to every socket except the one that is malfunctioning on Socket.io

My current task involves sending a message to all connected sockets on my server using socket.io. The code I have written so far looks like this: if(electionExists) { var connectedClients = io.sockets.adapter.rooms[electionRequested].sockets; ...

Am I making a mistake in my implementation of sending Socket.io messages to a designated room?

Upon a user joining, I alter their ID to a shortened random code. This change is made to utilize the id as a visible session ID on the front-end. I mention this to prevent confusion regarding non-standard socket IDs and their relation to potential issues. ...

Angular does not receive events from Socket.io

Recently I started coding with AngularJS and decided to build a real-time app using Socket.io: The service I'm using shows that the connection is fine on the console. Here's a picture of the Console.log output However, when I attempt to emit c ...

Debbuging problems with Azure web sockets and Socket.io

I'm currently developing a multiplayer chess game using NodeJS and socket.IO. I've been facing challenges trying to host it on Azure. I've attempted various approaches, including: Enforcing the use of WebSockets by adding the following code: io.configur ...

Redirecting the socket.io client to the Heroku service

Recently, I developed a real-time chat application using socket.io, Node.JS, and express. It was functional on my local server but now I want to connect it to an existing Heroku service instead. How can I achieve this? Once I tried the following code, va ...

Is it possible to maintain variables across a session with numerous users when utilizing socket.io?

My code structure is designed as follows: //Route Handler that triggers when a user 'creates a session' app.post('/route', async (req, res) => { let var1 = []; let var2 = []; io.on('connection', (socket) => ...

Verify the occurrence of a search result and if it appears more than once, only show it once using JavaScript

Hello all. Currently, I am developing an online users script using NodeJS and SocketIO. The functionality works fine, however, I am encountering an issue where if a user connects from multiple browsers, windows, or devices, it displays duplicate results li ...

Socket.io is notorious for making recurrent XHR requests

Whenever I establish a connection to the server socket from the client side, specifically using React, I notice that the socket client sends repeated requests every few seconds. These requests are primarily of the "get" type and often end up in a pending s ...

What are the steps to developing a chat application with MERN stack or another straightforward method?

What is the best way to develop a chat application for direct communication between two individuals? For instance, imagine a website with numerous producers where a consumer wishes to engage in a live chat with a specific producer. Any ideas on how to ach ...

Exploring the potential of Socket.io and Angular with the seamless integration of

I have encountered an issue regarding the use of async pipe with Observables. Initially, I assumed that returning an Observable from my service on a socket.on event would suffice. However, it appears that my approach is incorrect. Can you guide me on the c ...

Removing users from a Socket.IO chat room using Node.js

I am facing an issue with removing users from Socket.IO when their browser is closed. The 'user' in the array 'users[]' is not getting removed or updated. Additionally, I would like to update the users on the client side as well. Can someone assist me in r ...

Unable to establish connection between React Native Socket.IO and a Node.js server

As I work on developing a React Native Expo app that requires real-time communication using socket.io, my Node.js server is up and running on localhost. Here's the code snippet: In React Native - home.js import { io } from "socket.io-client"; c ...

Sending messages from one Socket.io server to another specific server

I am facing a unique scenario where a client (browser) connects to server A, which in turn is connected to server B and C. When the client sends a message to server A, I need to route that message to a specific server, either B or C, but not both. Essentia ...

Connection to socket.io refused due to ERR_CONNECTION_REFUSED

I am currently attempting to run a Node.js application on my server using SSH. When I run 'node server.js' in the terminal, everything seems to be running correctly: var express = require('express'); var app = express(); var server = app.listen(5431); app ...

Is there a correlation between the length of the first argument in the socket.emit function of socket.io and latency?

I am intrigued by whether there is a distinction, other than readability, between code snippets like: socket.emit('m','something'); and socket.emit('chat message','something'); Is switching from the second option to the first substantial enough in redu ...