Skip to content
This repository has been archived by the owner on Aug 2, 2021. It is now read-only.

plugin and app engine #1

Open
Pacane opened this issue May 8, 2015 · 6 comments
Open

plugin and app engine #1

Pacane opened this issue May 8, 2015 · 6 comments

Comments

@Pacane
Copy link
Contributor

Pacane commented May 8, 2015

Have you guys successfully deployed redstone with the web_socket_plugin to app engine managed vms?

I'got the the normal resources matching the end points, but it seems that on app engine (and even locally on gcloud) the requests never go to the methods

 @OnOpen()
  void onOpen(WebSocketSession session) {
    print("connection established");
  }

  @OnMessage()
  void onMessage(String message, WebSocketSession session) {
    print("message received: $message");
  }

This snippet works fine when I launch the server without gcloud. However, when I check the logs at startup I see that RedStone did its setup correctly (I suppose?)

configured websocket handler for /ws: socket_handler.WebSocketEndPoint

When querying the end point on my client I keep getting failed: Error during WebSocket handshake: Unexpected response code: 404

@cgarciae
Copy link

cgarciae commented May 8, 2015

Can you post your main?

@Pacane
Copy link
Contributor Author

Pacane commented May 8, 2015

Sure.. so I have a project, that I just want to wrap for the runAppEngine function from the appengine package.

So here's the main of my app-engine-wrapper project

import 'package:appengine/appengine.dart';
import 'package:redstone/server.dart' as app;
import '../../pkg/server/bin/main.dart' as server;

void main() {
  logger.info("Running server's main");
  server.mainAppEngine().then((_) {
    runAppEngine((HttpRequest request) {
      app.handleRequest(request);
    }
  }).catchError((e) => logger.severe(e));
}

Here's the function that setups redstone:

Future mainAppEngine() async {
  restPort = 4040;
  hostname = '0.0.0.0';

  await startGamesServer();
}

Future<HttpServer> startGamesServer() {
  logger.level = Level.FINE;
  setupLogging();

  app.addPlugin(getWebSocketPlugin());

  app.addModule(modules.getRestModule());

  return app.start(address: hostname, port: restPort).catchError(showError);
}

in modules.getRestModule() I bind all my resources + things that need to be injected + my class that hold @WebSocketHandler("/ws")

@cgarciae
Copy link

cgarciae commented May 8, 2015

See redstone-dart/redstone#49

@Pacane
Copy link
Contributor Author

Pacane commented May 8, 2015

Yeah, I used the code provided by @luizmineo in that issue, and it works fine for @app.Group() and @app.Route() on AppEngine, but doesn't seem to work with the @WebSocketHandler

@Pacane
Copy link
Contributor Author

Pacane commented May 8, 2015

I notices that the code provided by Luiz mentions that you have to not call app.start(). I've tried that too, and doesn't seem to work better. (Instead of calling the API on :4040 as in the sample above, I tried calling it with :8080).

@cgarciae
Copy link

cgarciae commented May 8, 2015

You should call

app.setup(); //<== Important
runAppEngine(app.handleRequest).catchError (...);

If that doesn't work, try a Redstone Hello World without websockets on App Engine just to make sure its really a problem of the plugin.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants