代码之家  ›  专栏  ›  技术社区  ›  Hamzeh Hirzallah

gae上的nodejs websocket

  •  1
  • Hamzeh Hirzallah  · 技术社区  · 6 年前

    我想在google app engine(gae)上部署nodejs websocket应用程序,我已经尝试了3天,但没有成功。

    我一直在出错 ERR_CONNECTION_TIMED_OUT

    这是我在nodejs中的app.js文件

    var WebSocketServer = require('ws').Server,
        wss = new WebSocketServer({ port: 65080 }),
        CLIENTS = [];
    
        console.log('WS listening on port 65080');
    // on new connection    
    wss.on('connection', function (ws) {
    
        console.log('incoming connection ....');
        ws.id = uuid.v4();
        CLIENTS.push(ws);
        ws.send('{"type":"uuid","value":"' + ws.id + '"}');
    });
    

    我已成功打开防火墙端口,如下所示

    enter image description here

    这是我的app.yaml

    runtime: nodejs
    env: flex
    api_version: 1
    service: websockets
    
    manual_scaling:
      instances: 1
    
    network:
      forwarded_ports:
      - 65080
      session_affinity: true
      instance_tag: websocket
    

    如有任何建议,我们将不胜感激。

    1 回复  |  直到 6 年前
        1
  •  1
  •   Victor Herasme Perez    6 年前

    this comment 在谷歌公共问题追踪系统上:

    enter image description here

    谷歌应用引擎似乎还没有灵活的网络接口。我建议你在这个问题上加上星号,这样你就可以跟踪更新了。