Socket.IO

Socket.io : “Cannot read property 'emit' of undefined”

人盡茶涼 提交于 2020-01-07 00:35:36
问题 So I'm currently developping my website using socket.io. Today, while I was implementing the sockets, I got a nice little error "Cannot read property 'emit' of undefined" I can not find what's wrong in my code so I hope you guys can help me. App.js: var socket = require( 'socket.io' ); var express = require('express'); var app = express(); var server = require('http').createServer(app); var io = socket.listen( server ); var port = 9999; server.listen(port, function () { console.log('Listening

SocketIO4Net - Error initializing handshake with https://localhost/

三世轮回 提交于 2020-01-06 14:37:07
问题 I'm trying to use SocketIO4Net to connect with my node.js server via socket.io. Can't seem to get it to work, when it comes to HTTPS. Getting this: Error initializing handshake with https://localhost/ Couldn't find a solution in other similar questions. If you have other solutions to connect to socket.io sockets from C# feel free to share the information. 回答1: .NET seems to block my self signed certificate. Implementing the RemoteCertificateValidationCallback seems to solve the problem.

Nginx reverse proxy for Socket.IO dropping messages at a certain size

好久不见. 提交于 2020-01-06 13:52:38
问题 I have nginx setup as a reverse proxy with the following config. worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; keepalive_timeout 65; map $http_upgrade $connection_upgrade { default upgrade; '' close; } server { listen 8080; server_name localhost; add_header X-Cache-Status $upstream_cache_status; location /node/ { proxy_http_version 1.1; proxy_pass http://127.0.0.1:8000/; proxy_redirect off; proxy_set_header Connection

Realtime websocket-like behavior possible on Heroku?

a 夏天 提交于 2020-01-06 12:36:52
问题 I am considering making a chess app in Rails where moves need to be pushed from the server to the client browser asynchronously (ideally with websockets). However, from what little research I've done it appears that Heroku does not support websockets. But there is an alternative in using socket.io configured to use long polling instead of websockets. Is long polling insufficient to achieve latency requirements for something like a 5 minute blitz game of chess? 回答1: The Heroku Cedar stack

Realtime websocket-like behavior possible on Heroku?

谁都会走 提交于 2020-01-06 12:36:07
问题 I am considering making a chess app in Rails where moves need to be pushed from the server to the client browser asynchronously (ideally with websockets). However, from what little research I've done it appears that Heroku does not support websockets. But there is an alternative in using socket.io configured to use long polling instead of websockets. Is long polling insufficient to achieve latency requirements for something like a 5 minute blitz game of chess? 回答1: The Heroku Cedar stack

Node Socket.IO socket.on() across multiple files

≡放荡痞女 提交于 2020-01-06 09:54:32
问题 I'm using Socket.IO in a node app and I wish to catch and respond to socket events in different files, how do I do it? One solution that I was able to find was to do this in the file that sets up the socket.io: var events = []; module.exports.setup = (server) => { io = require('socket.io')(server); console.log("Socket.io setup complete"); io.on('connection', (socket) => { for(let e of events){ socket.on(e.event, e.callback); } }); }; module.exports.on = (event, callback) => { events.push(

Node Socket.IO socket.on() across multiple files

白昼怎懂夜的黑 提交于 2020-01-06 09:54:30
问题 I'm using Socket.IO in a node app and I wish to catch and respond to socket events in different files, how do I do it? One solution that I was able to find was to do this in the file that sets up the socket.io: var events = []; module.exports.setup = (server) => { io = require('socket.io')(server); console.log("Socket.io setup complete"); io.on('connection', (socket) => { for(let e of events){ socket.on(e.event, e.callback); } }); }; module.exports.on = (event, callback) => { events.push(

passport-socketio breaks passport implementation?

为君一笑 提交于 2020-01-06 08:32:09
问题 This is my socket config: // set authorization for socket.io io.set('authorization', passportSocketIo.authorize({ cookieParser: express.cookieParser, key: 'connect.sid', // the name of the cookie where express/connect stores its session_id secret: '1234', // the session_secret to parse the cookie store: sessionStore, // we NEED to use a sessionstore. no memorystore please success: function (data, accept) { console.log('successful connection to socket.io'); // The accept-callback still allows

Node.js crashing automatically by mysql without any operation in it

*爱你&永不变心* 提交于 2020-01-06 08:25:14
问题 I am working with node.js and facing a problem with crashing of node . Error message shown below. Error: Connection lost: The server closed the connection. at Protocol.end (/var/www/versions/project/js/node_modules/mysql/lib/protocol/Protocol.js:78:13) at Socket.<anonymous> (/var/www/versions/project/js/node_modules/mysql/lib/Connection.js:81:28) at Socket.EventEmitter.emit (events.js:117:20) at _stream_readable.js:919:16 at process._tickCallback (node.js:419:13) I'm using mysql queries in

AWS Application Load Balancing: Seeing extremely long initial connection time

廉价感情. 提交于 2020-01-06 07:17:22
问题 From observer's perspective, symptoms are identical to the issue here Scenario is the same as well: Angular app which sends preflight requests to REST api, and preflight requests take in roughly 50% of times up to 1.3 seconds (illustration is the same as in the linked question). Also, websocket was frequently timing out until socket-io finally succeeded in establishing connection. Problem was more pronounced in Chrome and less in Safari/Firefox. However, we are using ALB and not ELB, and all