Feathers: 是否可以为 socket.io 设置不同的端口来部署 GAE Fixble

创建于 2017-03-28  ·  3评论  ·  资料来源: feathersjs/feathers

你好 ,

我想将羽毛部署到 GAE Fixble(谷歌应用引擎)
不幸的是,Google App Engine 的负载均衡器不支持 websocket。
所以,我需要设置socket.io监听端口与rest api不同(80、443)
是否可以为 sokect.io 设置不同的端口?

谢谢 。

最有用的评论

您应该能够像这样启动 REST 部分:

const http = require('http');

http.createServer(app).listen(80);

然后通过套接字服务器:

const socketServer = http.createServer().listen(3889);

app.setup(socketServer);

不要打电话给app.listen

所有3条评论

您应该能够像这样启动 REST 部分:

const http = require('http');

http.createServer(app).listen(80);

然后通过套接字服务器:

const socketServer = http.createServer().listen(3889);

app.setup(socketServer);

不要打电话给app.listen

感谢您的帮助,即使我有一些静态 ip 来处理套接字。
但我在 GAE 灵活部署上迈出了第一步。

这是我当前的 index.js

'use strict';

const http = require('http');
const app = require('./app');
const port = process.env.PORT || app.get('port');
const socketServer = http.createServer().listen(3889);
app.setup(socketServer);
const server = http.createServer(app).listen(port);
//  app.listen(port);

server.on('listening', () =>
  console.log(`Feathers application started on ${app.get('host')}:${port}`)
);

现在我可以部署到 GAE ,我可以调用 restful 使用http://my-app.appspot.com ,使用 ws://ip- address:3889调用 ws

由于关闭后最近没有任何活动,因此此问题已自动锁定。 请打开一个新问题,其中包含指向此问题的链接以获取相关错误。

此页面是否有帮助?
0 / 5 - 0 等级