Socket.IO

Multiple socket.io servers sharing a single HTTP/S server

萝らか妹 提交于 2020-06-17 03:50:07
问题 With ws, Node.js WebSocket library, it is possible to have multiple servers sharing a single HTTP/S server. Is it possible to do the same with socket.io? I need to have two WebSocket servers on the same HTTP server, one for socket.io and another one for Apollo subscriptions. I can set up Apollo subscription server with a Websocket server but not for socket.io, socket.io only accepts HTTP server. I thought in doing something like this: const socketioWsS = new WebSocket.Server({ noServer: true

Recommendation on how to document Websocket API [closed]

夙愿已清 提交于 2020-06-13 18:12:04
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . I've written a Websocket-API using socket.io. Let's say that after establishing the connection the server waits for a login -event with a payload like {username: String, password: String} . The server then answers with the events login:accept or login:deny . Only if the login

Recommendation on how to document Websocket API [closed]

一曲冷凌霜 提交于 2020-06-13 18:09:07
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago . I've written a Websocket-API using socket.io. Let's say that after establishing the connection the server waits for a login -event with a payload like {username: String, password: String} . The server then answers with the events login:accept or login:deny . Only if the login

How to access websocket from controller or another component/services?

。_饼干妹妹 提交于 2020-06-13 10:54:53
问题 I have a REST API, I want to send event to the client via websocket. How to inject websocket instance in controller or another component? 回答1: Better solution is to create global module . You can then emit events from any other module/controller. A. Afir approach will create multiple instances of Gateway if you try to use it in other modules. Note : This is just simplest solution Create socket.module.ts import { Module, Global } from '@nestjs/common'; import { SocketService } from './socket

Firebase Auth Are my variables secure/safe?

。_饼干妹妹 提交于 2020-06-01 07:41:26
问题 I am currently using heroku to store my environmental variables for my firebase authentication initialisation. I am using my server to get the environmental variables and send it to the client using socket.io. Below is what I mean. 1) Example of sending environmental variable to client from server: socket.emit('value', process.env.apiKey); 2) storing it as data[0] in the client: socket.on('value', function(data) { firebase.initializeApp({ apiKey: data[0], }); }) Is this safe? Can someone from

Firebase Auth Are my variables secure/safe?

拟墨画扇 提交于 2020-06-01 07:41:08
问题 I am currently using heroku to store my environmental variables for my firebase authentication initialisation. I am using my server to get the environmental variables and send it to the client using socket.io. Below is what I mean. 1) Example of sending environmental variable to client from server: socket.emit('value', process.env.apiKey); 2) storing it as data[0] in the client: socket.on('value', function(data) { firebase.initializeApp({ apiKey: data[0], }); }) Is this safe? Can someone from

socket.io net::ERR_CONNECTION_CLOSED

↘锁芯ラ 提交于 2020-05-29 06:52:36
问题 I am creating a multiplayer game with login system. However, there is one error, which I don't know how to solve. When I run my app I get the following error: net::ERR_CONNECTION_CLOSED. Here is my app.js var express = require('express'); var path = require('path'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var exphbs = require('express-handlebars'); var expressValidator = require('express-validator'); var flash = require('connect-flash'); var

socket.io net::ERR_CONNECTION_CLOSED

别说谁变了你拦得住时间么 提交于 2020-05-29 06:51:17
问题 I am creating a multiplayer game with login system. However, there is one error, which I don't know how to solve. When I run my app I get the following error: net::ERR_CONNECTION_CLOSED. Here is my app.js var express = require('express'); var path = require('path'); var cookieParser = require('cookie-parser'); var bodyParser = require('body-parser'); var exphbs = require('express-handlebars'); var expressValidator = require('express-validator'); var flash = require('connect-flash'); var

socket.io client reconnect timeout

我们两清 提交于 2020-05-25 07:25:13
问题 I'm using socket.io with node.js and I like the solution. The only issue I notice is around a disconnection and reconnection. These are my current settings: 'connect timeout': 1000, 'reconnect': true, 'reconnection delay': 300, 'max reconnection attempts': 10000, 'force new connection':true I notice if I stop and start the node.js process the client connects back fine and quickly, however if the server is offline for a couple of minutes the client either never reconnects or takes a very long

WebSocket connection to <URL> failed: Error during WebSocket handshake: Unexpected response code: 521

こ雲淡風輕ζ 提交于 2020-05-24 04:53:08
问题 I have a problem with connecting to the socket server. WebSocket connection to <URL> failed: Error during WebSocket handshake: Unexpected response code: 521 I have two different cloud server (1) for a client project and (2) for a socket server. (1) Client Project: var token = "{{ csrf_token() }}"; window.Echo = new Echo({ broadcaster: 'socket.io', host: "{{env('SOCKET_SERVER_HOST')}}", origin: '*', transports: ['websocket', 'polling', 'flashsocket', 'ws', 'wss'], auth: { headers: { 'X-CSRF