带有Socket.IO的Google App Engine/计算引擎 [英] Google App Engine/Compute Engine with Socket.IO

查看:105
本文介绍了带有Socket.IO的Google App Engine/计算引擎的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在AppEngine上启动了我的NodeJs应用程序后,我发现它引发了一个异常:app.min.js:20 WebSocket连接到'wss://hostname/socket.io/?EIO = 3& transport = websocket& sid = OClcQulfAmcJEpfMAAAV失败:WebSocket握手期间出错:意外的响应代码:400

Having launched my NodeJs app on AppEngine, i found it throws an exception: app.min.js:20 WebSocket connection to 'wss://hostname/socket.io/?EIO=3&transport=websocket&sid=OClcQulfAmcJEpfMAAAV' failed: Error during WebSocket handshake: Unexpected response code: 400

尝试使用Google时,我发现Google Cloud似乎不支持WebSockets.由于应用是编写的,而且我们没有太多时间来重写它,还有其他方法可以保持现状并让socket.io与Google Cloud一起工作吗?是否可以单独运行Socket.IO服务器并通过它进行通信?将应用程序移至Compute Engine上的独立VM可以解决该问题,或者甚至不支持套接字吗?

Trying to google, i found Google Cloud does not seem to support WebSockets. Since app is written and we have no much time to rewrite it, are there any other ways to keep things as is and have socket.io working with Google Cloud? Is it possible to run Socket.IO server separately and communicate through it? Having app moved into standalone VM on Compute Engine could solve it or sockets are`t supported even there?

跟进:我发现它可以在Chrome上运行,因为它会自动切换到池传输.

Follow up: i found it works on Chrome though, as it switches automatically to pooling transport.

推荐答案

可以使用运行Node.js的Flexible Environment来完成.但是,

It can be done using Flexible Environment running Node.js. However,

注意:App Engine当前不支持安全WebSockets 灵活的环境. WebSockets仅在您加载页面时才能工作 通过HTTP(不是HTTPS).

Note: Secure WebSockets are currently not supported by App Engine Flexible Environment. WebSockets will only work if you load your page over HTTP (not HTTPS).

https://github.com/GoogleCloudPlatform/nodejs -docs-samples/tree/master/appengine/websockets

要添加,有一个beta版支持使用typhoonae的GAE Web套接字.这是那些有兴趣的人的链接: https://code.google.com/archive/p/typhoonae/wikis/WebSockets.wiki

To add, there is a beta that supports Web Sockets for GAE using typhoonae. Here's the link for those interested: https://code.google.com/archive/p/typhoonae/wikis/WebSockets.wiki

这篇关于带有Socket.IO的Google App Engine/计算引擎的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆