moleculerjs / moleculer-web

:earth_africa: Official API Gateway service for Moleculer framework
http://moleculer.services/docs/moleculer-web.html
MIT License
291 stars 119 forks source link

Moleculer java and Moleculer Node.js can't run where configured on the same transporter #185

Closed oloohezbon closed 4 years ago

oloohezbon commented 4 years ago

Prerequisites

Please answer the following questions for yourself before submitting an issue.

Current Behavior

When you configure moleculer java to use the same transport as moleculer js, molecular js crashes. with below error.

Expected Behavior

I was expecting the two to work together. I see moleculer java discovers the moleculer js services but moleculer js crushes during discovery.

Failure Information

index.js:1384 const basePath = addSlashes(_.isString(service.settings.rest) ? service.settings.rest : serviceName.replace(/./g, "/")); TypeError: Cannot read property 'rest' of undefined

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Create a project molecularjs web latest version.
  2. Create moleculer java service Maven version1.2.12 , moleculer java web 1.2.8
  3. Configure sam transporter, I used NATS
  4. Run the two concurrently and you will get the crash.

Reproduce code snippet

Java moleculer service; `ServiceBrokerConfig cfg = new ServiceBrokerConfig();

    NatsTransporter transporter = new NatsTransporter("nats://localhost:4222");
    //transporter.setVerbose(true);
    //transporter.setDebug(true);
    //transporter.setNoEcho(true);
    cfg.setTransporter(transporter);

    ServiceBroker broker = new ServiceBroker(cfg);

    ApiGateway gateway = new ApiGateway();
    Route route = gateway.addRoute(new Route("/fer"));

route.addToWhiteList("*");

    broker.createService(new NettyServer());
    broker.createService(gateway);
    broker.createService(new GreeterService());

    broker.start();`