Sails.js Google App Engine 上的套接字问题

Sails.js Socket Issue on Google App Engine

我 运行 Sails.js (v0.11.0) 在 Google App Engine 的托管 VM 上,一切正常 提供我禁用套接字。我正在使用默认的 Sails 项目,其中一个模型(用户)没有自定义属性,我只是在我的浏览器中访问主页。我在 Chrome 的控制台 window;

中看到以下内容
WebSocket connection to 'ws://localhost:8080/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=websocket&sid=GShPZd_tjzqnrigNAAAA' failed: Error during WebSocket handshake: 'Upgrade' header is missing
sails.io.js:143 

  |>    Now connected to Sails.
\___/   For help, see: http://bit.ly/1DmTvgK
        (using browser SDK @v0.11.0)



4(index):1 Font from origin 'http://sailsjs.org' has been blocked from loading by Cross-Origin Resource Sharing policy: The 'Access-Control-Allow-Origin' header contains the invalid value ''. Origin 'http://localhost:8080' is therefore not allowed access.
sails.io.js:4 POST http://localhost:8080/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_s…ascript&EIO=3&transport=polling&t=1427404282042-3&sid=GShPZd_tjzqnrigNAAAA 503 (Service Unavailable)
sails.io.js:143  Failed to connect socket (probably due to failed authorization on server) Error: Error: xhr post error {type: "TransportError", description: 503, stack: (...), message: "xhr post error"}
sails.io.js:143  ====================================
sails.io.js:143  Socket was disconnected from Sails.
sails.io.js:143  Usually, this is due to one of the following reasons:
 -> the server was taken down
 -> your browser lost internet connectivity
sails.io.js:143  ====================================
sails.io.js:143  
        Socket is trying to reconnect to Sails...
_-|>_-  (attempt #1)


sails.io.js:4 POST http://localhost:8080/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_s…ascript&EIO=3&transport=polling&t=1427404302073-4&sid=GShPZd_tjzqnrigNAAAA 503 (Service Unavailable)
sails.io.js:4 GET http://localhost:8080/socket.io/?__sails_io_sdk_version=0.11.0&__sails_io_s…sails_io_sdk_language=javascript&EIO=3&transport=polling&t=1427404303080-5 503 (Service Unavailable)

'Upgrade header is missing' 似乎是罪魁祸首,但我不明白 headers 是如何根据 Socket.io 的要求进行更改的,我有一个 app.yaml 只允许将所有流量传递给 sails 的文件。

#app.yaml
module: default
version: 1
runtime: custom
api_version: 1
vm: true
manual_scaling:
    instances: 1

handlers:
    - url: /.*
    script: app.js

非常感谢任何帮助!

干杯! R.

我认为您无法开箱即用地使用 Sails 的网络套接字。 Google App Engine 不是我熟悉的东西,但您似乎需要将其 API 用于网络套接字。看这个例子:

https://github.com/thebergamo/appengine-websocket-nodejs

经过更多的探索之后,我最终发现了这个 post,它几乎是这个的副本,应该会给你一些更多的线索。简短的回答是你需要有一个单独的 Google 托管 VM 运行 你的网络套接字服务,然后你直接通过 ip 地址访问它,这似乎让使用 Sails 失去了所有乐趣。

Run Websocket on GAE