Socket.IO

Socket.IO - cannot load XMLHttpRequest in Google Chrome

允我心安 提交于 2020-01-15 04:29:07
问题 I'm trying to get very first example from socket.io home page working in Chrome(19.0.1048.46) but I get the error: "XMLHttpRequest cannot load http:// localhost:8080/socket.io/1/?t=1337156198176. Origin null is not allowed by Access-Control-Allow-Origin." Server code: var app = require('http').createServer(handler) , io = require('socket.io').listen(app) , fs = require('fs') app.listen(8080); function handler (req, res) { fs.readFile(__dirname + '/index.html', function (err, data) { if (err)

Registering server events with flask SocketIO

不想你离开。 提交于 2020-01-14 13:37:44
问题 I'm getting started with flask and SocketIO using https://github.com/miguelgrinberg/Flask-SocketIO. I want to post a string to the flask server and then via SocketIO, emit this to the client webpage. Normally my posting code would look like: @app.route('/index',methods=['POST']) def index(): token = request.form['token'] As far as I understand, something like the following is needed to emit data from the server to client page: @socketio.on('event', namespace='/test') def test_message(message)

content-security-policy meta tag for allowing web socket

爱⌒轻易说出口 提交于 2020-01-14 08:45:08
问题 Situation: autoreload of phonegap serve blocked by content-security-policy meta tag Adding content security policy prevents auto-reload of phonegap serve utility. This is built on top of cordova serve but auto-reloads the app on file editing. It works by injecting socket.io in index.html . What should I specify in my CSP meta tag that will allow socket connections to my laptop. Here is my current CSP meta tag: <meta http-equiv="Content-Security-Policy" content="default-src 'self' 192.168.0

'Missing PFX or certificate + private key.' in https socket.io

喜你入骨 提交于 2020-01-14 08:44:10
问题 I have been having this problem for quite some time now but couldn't figure it out... Nothing I try really works at all. From conversions of the ssl files into many different formats and checking folder permissions nothing worked (or, to be more explicit, it all is as it should be to work). Does anyone know what could be off? Thank you very much for your help, I'm getting to the desperate side at this point... Could this be version related? How could I check if that's the case? Here is my

AngularJS: chat app with socket.io over https

一曲冷凌霜 提交于 2020-01-14 08:35:09
问题 I am running this example chat app https://github.com/btford/angular-socket-io-im that uses socket.io/angular/node to make a basic im client. However I run into trouble when I try to make it work over https. No socket events are caught on the server, so no chat messages are sent to clients and users can't join rooms. I also get this error on the client in socket.io.js : Uncaught TypeError: Cannot call method 'onClose' of null I've created an express https server listening on port 8000 and

I want to send data from many clients to one stable client using Node.js

狂风中的少年 提交于 2020-01-14 06:03:28
问题 Here is my code: var express = require('express'); var net = require('net'); var app = express(); //first of all connect to a stable client var server = net.createServer(function(socket) { // do nothing here . what i want is to use this socket in // (following) app.get() function }); server.listen(1337, '127.0.0.1'); //receive request from other clients app.get('/', function (req, res) { // retriving mobileNumber and message var mobileNumber = req.query.mobileNumber; var message = req.query

Socket.IO multiple pages for same user/socket

穿精又带淫゛_ 提交于 2020-01-14 02:53:26
问题 I'm working on a multiplayer board game on Node.js/Socket.IO. The flow is the following : user enters his name and is added to the lobby user select a room and is added to it, then game starts when he is joined by another user. This part is petty easy and I've done it before. However, I now need the user to be able to join multiple game rooms at the same time. pages are dynamically generated by express, and there's no issue opening many game pages, but I'm struggling with the socket

Ionic app won't connect to Socket.IO

梦想的初衷 提交于 2020-01-13 14:29:37
问题 I have a small node app set up for Socket.IO connections: var app = require('express')(); var server = require('http').Server(app); var io = require('socket.io')(server); io.on('connection', function (socket) { console.log('socket connected'); socket.on('disconnect', function () { console.log('socket disconnected'); }); socket.emit('text', 'wow. such event. very real time.'); }); server.listen(3000, function() { console.log('Socket.io Running'); }); In my Ionic app I have the following:

Socket.IO - How to change timeout value option on client side?

Deadly 提交于 2020-01-13 03:45:08
问题 I use Socket.IO 0.9.16 to establish a connection: io.connect(url) However, when the server dies, it takes 2 minutes timeout to detect error with the server. I already tried to reduce timeout to 5s by setting: io.connect(url, {'timeout': 5000, 'connect_timeout': 5000}) But no success... How can I do this? 回答1: The challenge here is that there are a bunch of different settings that interact with each other and some retry logic that all make a socket.io timeout not what you would normally expect

socket.io as a client

谁都会走 提交于 2020-01-12 18:43:07
问题 is there any way to run socketio as a client(not a browser, but a nodejs script) I need to broadcast data from a server to some clients (browsers) and to another linux machine (only running nodejs to get variables, no browser) Any ideias is welcome Regards 回答1: There is a project on github which implements a socket.io client. Take a look here: https://github.com/remy/Socket.io-node-client var socket = new io.Socket('localhost', 8000); socket.on('connect', function () { console.log('yay,