Tag: sockets

Node – ENONET when connecting to a socket

Executing this code: var fs = require(‘fs’); var Socket = require(‘net’).Socket; var socket = new Socket(); console.log(‘connecting to: ‘ + server.host + ‘:’ + server.port ); socket.connect( server.host, server.port ); socket.on(‘error’, function(err) { console.log(arguments); }); socket.on(‘connect’, function() { console.log(‘connected’); }); socket.on(‘end’, function() { console.log(‘socket ended’); }); Always throws this error: { ‘0’: { [Error: connect […]

node.js get file descriptor of socket?

How can I get the file descriptor (respectively its path) of a socket? I can open a file descriptor when I know its path like this: var fd = require(“fs”).createReadStream(pathOfFileDescriptor); for example require(“fs”).createReadStream(“/proc/”+process.pid+”/fd/0”).on(“data”,function(d){ console.log(“The following data comes from stdin: “+d); }); Now, how can I know which file descriptor file is for which socket? Hope […]

Nodejs Websocket Close Event Called…Eventually

I’ve been having some problems with the below code that I’ve pieced together. All the events work as advertised however, when a client drops off-line without first disconnecting the close event doesn’t get call right away. If you give it a minute or so it will eventually get called. Also, I find if I continue […]

Only disconnect one socket when error occurs in NodeJS program

Currently when an error occurs in a NodeJS server (eg: Buffer “out of bounds”), the entire server grinds to a halt. Is there a way to configure it such that only the socket on which the error occured gets disconnected leaving the server online and the other connections active? I could use the “uncaughtException” error […]

NodeJS socket FIN_WAIT2

I have a running nodejs server for socket communication with clients. After a period of time (few days) nodejs gets to 100% CPU usage. Looking at netstat for node port I found more than 1k connections with FIN_WAIT2 status (there should be only about 50 active connections). I’m using timeout function for connections, calling end() […]

HAProxy Configuration – How to make TCP connection sticky (Node.js, socket.io, websocket, FlashSocket)

I have setup HAProxy for EC2 server where i’m running my nodejs two server on port 3005 and 3006. we have setup this for our multiplayer game. we have used socket.io for our realtime event update on client side and server side. HAProxy is working correctly with “balance source” (I have added working copy of […]

Prevent new connection in new tab using node express and socket

Stop creation of new connection in different tab in node express and socket I am developing a chatting app which made to run on port 3000 using node, express and socket. I just want to stop creation of socket connection between client and server if other tab of same browser hits same url. Can some […]

Build Meteor in Docker cannot pass proxy setting

I use latest Nodejs image as base image to build meteor project. The docker is behind the corporate proxy. I tried curl and npm install -g. Both of them can go through the proxy and download packages. However, when I try to use meteor update, error prompts as: Unable to update package catalog (are you […]

Websocket proxy pass to different routes

Im trying to setup different socket.io servers under different locations for example: socket.yourdomain.com/app1 socket.yourdomain.com/app2 exectra… This subdomain is secured using a valid ssl certificate and not self signed. nginx vhost server { listen 443; ssl on; ssl_certificate /etc/nginx/ssl/some_cert_chain.crt; ssl_certificate_key /etc/nginx/ssl/somekey.key; server_name socket.yourdomain.com; location / { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection “upgrade”; proxy_set_header Host […]

React native + SSL socket: Error: xhr poll error

I’m using socket.io-client to connect socket from react native app with ssl socket server and get an error at connect-error event – [Error: xhr poll error]. Here is my code from react native (client side): import io from ‘socket.io-client’; import Config from ‘../../config’; var socketConfig = { secure: true } function connect() { this.socket = […]

Node.js is the Best Javascript runtime in the world.