News Articles sockets

Socket IO client + React Typescript + Context API causing TypeError: Cannot assign to read only property ‘exports’ of object ‘#<Object>’

I am using context API to delegate socket io client instance to other child components, once I declare a socket io client instance, react app throws TypeError: Cannot assign to read only property ‘exports’ of object ‘#’ import { createContext } from ‘react’; import { io } from ""; const socket = io("http://localhost:5000"); // < […]

How to achieve Peer to Peer networking in NodeJS

Here is some background on what I’m trying to achieve: I am creating a BlockChain, I am wanting to achieve a network where all NodeJS programs can connect to each other without needing to port forward. I have used SocketIO, UDP Sockets, REST Servers, But all of these need to be port forwarded in order […]

Selecting Server for NodeJS, MongoDB, SocketIO

Context: Hi, I’m Using a Linode Server currently (Dedicated 8GB Plan) and I’m Not Sure Which Resources I Need for my App and whether the Current Config is Overkill or Underpowered. App Details: My Application is a NodeJS App using MongoDB as a Database and SocketIO as a Connection to Clients. The Type of Data […]

Reuse socket connection while avoiding stale React hooks closure

Here is a simplified version of my problematic code. I’m trying to create a socket connection (Rails Action Cable) in such a way that it doesn’t get recreated on each render (tried that first and Chrome crashed). At the same time the code that needs to run when an update comes in over that socket […]

How to emit events associated with namespaces in Socket IO

I have been working on a React App which should communicate with a socket server ( v2) to get and post information. Assume that the server is hosted at and I am successfully able to connect to the server and send the "pong" event and logging the latency. Now according to the socket API […]

How to include javascript to my Express.js app which also using socket io?

This is countdown project, and for time sync i’m using server.js const app = require(‘express’)(); const http = require(‘http’).Server(app); const io = require(‘’)(http); const port = process.env.PORT || 3000; var timesyncServer = require(‘timesync/server’); app.get(‘/’, (req, res) => { res.sendFile(__dirname + ‘/index.html’); }); app.get(‘/admin’, (req, res) => { res.sendFile(__dirname + ‘/admin.html’); }); io.on(‘connection’, (socket) => […]

How i can get data from C++ backend server to react js client side?

I am working on a project in which speed matters.For this purpose, I used c++ as a backend language for the complex algorithms. This part is done Now I am generating data on the backend server. now I want to display this data in real-time on react js front end. How I can use a […]

Node `net` module IPC server intermitent

Following the official node documentation off net and child_process modules, I reached this, a server that spawns a child and connect through net module. But this is intermitent. The code is self explanatory, I’ll try to resume the with comments in the code: // server.js const childProcess = require(‘child_process’).fork(‘child.js’); const server = require(‘net’).createServer((socket) => { […]

WebSocket needs browser refresh to update list

My project works as intended except that I have to refresh the browser every time my keyword list sends something to it to display. I assume it’s my inexperience with Expressjs and not creating the route correctly within my websocket? Any help would be appreciated. Browser let socket = new WebSocket("ws://localhost:3000"); socket.addEventListener(‘open’, function (event) { […]

The Code is working fine in console but not when adding into file-Uncaught TypeError: Cannot read properties of null (reading ‘style’) [duplicate]

Note: Please dont delete this question before looking into – I have seen all the given solution on stackoverflow and tried all but not worked for me please see my code and and see the problem which am getting am getting problem from 3-4 days and looking for it whole day in every site but […]

The Code is working fine in console but not when adding into file-Uncaught TypeError: Cannot read properties of null (reading ‘style’) [duplicate]

I am working on Chat application project using and added one left side navbar on it but its button not working and giving me error but when i am adding that same code into the console its working. help me out and thanks <script type="module" defer> let result=function(){ let sidebar = document.querySelector(".sidebar"); let closeBtn […] client automatically disconnecting in long Node.js function

I am using to communicate the swift client of my app with the server. Essentially, the client joins a socket connection upon opening the app and a job is instantly added to a Redis queue (it’s a job that takes anywhere from a few seconds to like 15ish seconds). There’s a response from the […]

Why is my Javascript socket connecting to a web server but not to localhost?

I am creating an plugin for Adobe FrameMaker using ExtendScript (which is basically Javascript with a bunch of FM-specific objects and methods). As there is no browser I cannot use any of the web-based libraries to connect to a server. I have been using a Socket and it works fine when I connect to one […]

Socket.emit only works after reloading the page

I tried to create a small simple socket js website that would send a message from one client to the other. I ran it on, and I opened 2 sites, but when I click the send button, it doesn’t work. I have to reload one of the clients for it to work. Here is […]

how to use setState() in socket.IO

when i click btn i have to make socket.emit() to server and after that get response from server by using socket.on(); if data ="003" i want to setState(). socket.on("/PcBytes", function (data) { var str = data.trim(); if (str.slice(str.length – 6, str.length – 4) === "31") { console.log("Working", str); this.setState(() => { valresponceTp0 = 1; responceTp0 […]

Socketio: Incorrect data is receiving in listener while sending bunch of calls

I am currently bringing in my own project, in which I am replacing my existing node.js request and response with socket now, I am using socket connect like below. Client side: client.js constructor( VaultServerURL ) { this.connection = io.connect(); } this.connection.emit("RestCall", { requestUniqueID: requestID, path: RequestPath, grpcRequestOptions: requestOptions }); this.connection.on(requestID, function (data) { var […]

how to use http requests with events in one server

i have io server with sockets and i also need to add some routes to my http requset. I try to add some middleware throught app.use but this method doesn’t work for me. I also now have cors problem when i try to send request by it’s route despite i try to add ‘cors’ lib […]

Socket.on not receiving events after reconnecting in React (

I have written some code where when socket.disconnect() is triggered it should re initiate the socket from the client using socket = io(BASE_URL, { reconnection: true, reconnectionDelayMax: 10000, reconnectionDelay: 1000, reconnectionAttempts: 5 }); socket.on(‘connect’, () => { // … }); But after it reinitiates the socket and sends the new, none of the listeners […]

Sitemap | Terms | Privacy | Cookies | Advertising

Senior Software Developer

Creator of @LzoMedia I am a backend software developer based in London who likes beautiful code and has an adherence to standards & love's open-source.