1

I'm running Sails.js (v0.11.0) on a Managed VM in Google App Engine, everything works fine provided I disable sockets. I am using the default Sails project, with one model (User) with no custom attributes and am simply visiting the home page in my browser. I see the following in Chrome's console 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' seems like it may be the culprit, but I don't understand how the headers could have been changed from whatever Socket.io requires, I have an app.yaml file that simply allows passes all traffic to sails.

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

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

Any help greatly appreciated!

Cheers! R.

Ryan Loader
  • 185
  • 1
  • 8

1 Answers1

0

I don't think you're going to be able to use Sails' web sockets out of the box. Google App Engine is not something I'm familiar with, but it appears you need to use their API for web sockets. See this example:

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

After doing some more poking around I eventually came across this post, which is pretty much a duplicate of this one and should give you some more clues. The short answer is you need to have a separate Google Managed VM running your web socket service and then you access it directly via ip address, which seems to take all the fun out of using Sails.

Run Websocket on GAE

Community
  • 1
  • 1
HeadCode
  • 2,770
  • 1
  • 14
  • 26
  • Thanks HeadCode it certainly does seem that way. If no one can answer on the contrary in the next few days, I'll accept this as correct. – Ryan Loader Mar 27 '15 at 08:35
  • It is not possible to get this working at this time, websockets do not work with GAE: http://stackoverflow.com/questions/36116039/im-not-sure-what-im-missing-to-make-this-app-work-correctly-on-google-cloud-wh . Use compute engine instead it seems – cfl Mar 29 '16 at 11:24