带有Express的Socket.IO不能使用https(Apache2 Ubuntu16.04)

我不是很有经验的SSL证书,我跳了一个人可以帮助我找出我做错了什么。 我正在尝试使用端口443(从中服务器客户端应用程序而不是NodeJS / Express / Socket.io应用程序)启用了SSL的Apache2来托pipe带有自己端口(*:1729)的NodeJS应用程序。 当我用http设置Express时,它工作正常,我的客户端应用程序没有错误地与NodeJS应用程序通信,但是当我使用https这样的express时: this.express = require('express'); this.app = this.express(); var https = require('https'); var fs = require('fs'); var sslPath = '/etc/letsencrypt/live/yourdomain.example.com/'; var options = { key: fs.readFileSync(sslPath + 'privkey.pem'), cert: fs.readFileSync(sslPath + 'fullchain.pem') }; this.server = https.createServer(options, this.app); this.io = require('socket.io').listen(this.server); this.server.listen(1729); 当我的客户端应用程序尝试连接时,我得到这个错误: node: ../src/util-inl.h:196: TypeName* node::Unwrap(v8::Local<v8::Object>) [with TypeName = node::TLSWrap]: […]

反应:防止点击滚动条传播

我有一个可滚动的div,不幸的是我也有事件关联在div上的onMouseDown。 我的问题是,当我想通过点击滚动条滚动那些事件然后被解雇。 有没有办法让它,所以我可以防止滚动条上的鼠标事件传播?

如何同时使用“web-push”和“fcm-push”节点包?

我一直在尝试使用Firebase云消息传递和一些节点包来设置Web推送通知服务器/客户端体系结构。 经过多个教程,我真的很困惑。 我尝试了“web-push”节点包,但它需要gcm-key,正如谷歌宣布的那样,GCM现在正在转向FCM。 所以,我看了另一个名为“fcm-push”的软件包,但它不支持VAPID。 我甚至不确定为什么VAPID需要分开。 所以,我会在这里提出一些直接的问题 – 为什么有两个单独的键,即GCM / FCM和VAPID? 一旦我从客户端获得订阅密钥到服务器,我是否需要将它们存储在数据库中? 有没有其他方法可以用来保存它们? 它看起来像“fcm-push”包不支持VAPID键,它的文档只提到它的iOS和Android。 另一方面,“web-push”包不支持FCM。 那么,我应该同时使用这两个软件包吗? 如果是的话,那么我应该依靠什么软件包来完成哪个function?

如何撤销由OAuth从谷歌提供的令牌? 的NodeJS

我已经通过使用oauth2从我的NodeJS应用程序连接到谷歌加,但如何撤销令牌/断开? 我不能在NodeJS的文档中find任何东西。

如何连续调用函数

我希望能够持续运行这个代码,以便我调用的函数总是检查input是true还是false index.js io.on('connection', function(socket) { var entered = require('./main.js').onProximityBoolean; /// i want this to continuously be checking itself if (entered == true) { socket.emit('enterProximity'); } } main.js var enter = false; function onProximityBoolean(enter) { if (enter === true) { console.log(enter); return true; } else { return false; } } function isWithinBounds() { //inside here is […]

如何使用HTTP API从gcr.io Docker Registry列出图像和标签?

我试图从Node.js中的Google Container Registry(gcr.io)中获取可用图像及其标签的列表。 我首先使用google-auto-auth来调用范围为https://www.googleapis.com/auth/devstorage.read_write的令牌,然后将该令牌gcr.io令牌,如下所示: axios.get('https://gcr.io/v2/token?service=gcr.io', { auth: { username: '_token', password: token // token I got from `google-auto-auth` } }) 然后我尝试使用它来调用v2/_catalog端点: axios.get('https://gcr.io/v2/_catalog', { headers: { Authorization: `Bearer ${gcrToken}` } }) 我得到以下错误: { errors: [ { code: 'DENIED', message: 'Failed to retrieve projects.' } ] } 公平的,它必须要求我的项目ID,但我应该在哪里提供它? 只是为了看看我能不能做其他工作,我试过了: axios.get('https://gcr.io/v2/my-project-id/my-image/tags/list', { headers: { Authorization: `Bearer ${gcrToken}` } […]

文件循环function

我在node.js中创build了一个循环遍历目录文件的函数。 它应该将文件名添加到returnDatavariables,然后返回returnData。 但是,它一直没有返回。 我已经在函数中放了几个console.log语句来帮助我debugging,但我无法弄清楚为什么它不起作用。 function loopMusic (directory) { var returnData = ""; fs.readdir (directory, function (err, files) { if (err) { console.log (err); } files.forEach (function (file, index) { returnData += file; console.log (returnData); }); }); console.log (returnData); return returnData; } 第一个console.log语句能够打印这些文件,但是在返回之前的那一行只是打印一个新行。

Redux – 通过键在状态数组中查找对象并更新其另一个键

我正在使用后端的NodeJS和前端的React + Redux的CRUD应用程序。 这是一个如何运作的快速模式: 添加一个项目 用户inputpost的标题 然后将标题发送到在NodeJS中获取POST路由并通过主体发送标题的调度 在NodeJS路由中,我添加了一个新的项目集合与该标题 BACKEND DONE,新的post在服务器中 我在步骤2中添加.then()调度function,其中我派遣一个type: 'ADD_POST'并post: post (我从res.json({post: result from database}) ) 在我的reducer中,我设置了一个CASE 'ADD_POST': return action.post 完成FRONTEND后,用户现在可以看到同一个post,而不需要刷新 我想使用相同的逻辑来更新特定post的喜好 。 这是我迄今为止所做的: 点击一个post上的button会触发一个获取NodeJS PUT路由的调度 NodeJS路由查找使用ID的文章,并添加1到喜欢该post的旧值 BACKEND DONE,现在在服务器上有1个以上 我再次添加到获取NodeJS路由的调度中,在该调度中,我分配了一个type 'ADD_LIKE'的操作,并更新了更新的post ID 在reducer中,我设置了一个CASE 'ADD_LIKE':它使用下面代码片段中的代码遍历整个状态。 这是这个片段: state.map(item => { if(item.id === action.postid) { //i find the specific item, but now im stuck on how […]

PhantomJS错误

error: Could not spawn [/root/AgarioBotsV3/node_modules/phantomjsprebuilt/lib/phantom\bin\phantomjs.exe ] executable. Please make sure phantomjs is installed correctly. error: Error: spawn /root/AgarioBotsV3/node_modules/phantomjs- prebuilt/lib/phantom\bin\phantomjs.exe ENOENT at exports._errnoException (util.js:1016:11) at Process.ChildProcess._handle.onexit (internal/child_process.js:189:19) at onErrorNT (internal/child_process.js:366:16) at _combinedTickCallback (internal/process/next_tick.js:102:11) at process._tickCallback (internal/process/next_tick.js:161:9) at Function.Module.runMain (module.js:607:11) at startup (bootstrap_node.js:158:16) at bootstrap_node.js:575:3 error: Could not spawn [/root/AgarioBotsV3/node_modules/phantomjsprebuilt/lib/phantom\bin\phantomjs.exe ] executable. Please make sure phantomjs is […]

如何通过package.json下载并安装所有节点模块?

我想通过maven调用和下载所有节点模块,在maven我已经定义了插件来安装它,但现在在我的package.json我已经定义了下面的npm install命令,请告诉我如何安装所有的节点模块,并可以定义他们在package.json 的package.json { "name": "MyProject", "version": "1.0.0", "author": "Saral", "scripts":{ "start":"node gulpfile.js", "prebuild": "npm install", "build": "gulp" }, "dependencies": { "gulp": "*", "gulp-ruby-sass": "*", "gulp-util": "*", "gulp-rename": "*", "gulp-concat": "^2.6.0", "gulp-concat-vendor": "0.0.4", "map-stream": "*", "gulp-livereload": "*", "gulp-concat": "*", "gulp-uglify": "*", "gulp-minify-css" : "^1.2.1", "gulp-notify":"2.2.0", "gulp-inject": "1.5.0", "run-sequence": "1.1.4", "stream-series": "0.1.1", "gulp-gzip": "1.2.0", "gulp-clone": "1.0.0", […]