CoderSerio opened a new issue, #387:
URL: https://github.com/apache/dubbo-js/issues/387

   
   ## Relevant Code
   The relevant code is as follows
   1. proto
   ```proto
   syntax = "proto3";
   
   package apache.dubbo.demo.helloworld;
   
   message SayRequest {
     string sentence = 1;
   }
   
   message SayResponse {
     string sentence = 1;
   }
   
   service MyService {
     rpc Say(SayRequest) returns (SayResponse) {}
   }
   ```
   2. dubboRouter
   ```ts
   import { DubboRouter } from "@apachedubbo/dubbo";
   import { MyService } from "../../common/gen/example_dubbo";
   
   export default (router: DubboRouter) => {
     router.service(
       MyService,
       {
         async say(req, resp) {
           console.log(`Client say: ${req.sentence}`, req);
           return {
             sentence: `Server say: ${req.sentence}`,
           };
         },
       },
       { serviceGroup: "dubbo", serviceVersion: "1.0.0" }
     );
   };
   ```
   3. server
   ```ts
   import { createServer } from "http";
   import { dubboNodeAdapter } from "@apachedubbo/dubbo-node";
   import dubboRoutes from "./router";
   
   const server = createServer((req, res) => {
     console.log("get a request!", req);
     // key code is here @jianyi-gronk 
     dubboNodeAdapter({ routes: dubboRoutes });
     res.end("Response");
   });
   
   server.listen(8000, () => {
     console.log("\ndubbo-js server is running on http://localhost:8000...\n";);
   });
   ```
   4. client
   ```ts
   import { createPromiseClient } from "@apachedubbo/dubbo";
   import { createDubboTransport } from "@apachedubbo/dubbo-node";
   import { MyService } from "../../common/gen/example_dubbo";
   
   const transport = createDubboTransport({
     baseUrl: "http://localhost:8000";,
     httpVersion: "1.1",
   });
   
   const main = async () => {
     const client = createPromiseClient(MyService, transport, {
       serviceVersion: "1.0.0",
       serviceGroup: "dubbo",
     });
     const res = await client.say({ sentence: "Hello World" });
     console.log(res.sentence);
   };
   
   main();
   ```
   
   ## Steps to reproduce
   
   1. run the server
   2. run the client
   > the http request from client is received by server successfully, but the 
API `dubboNodeAdapter` throw a error
   
   ## Bug
   
   ![O9EYDG{)F0E44A8 
YJK3045](https://github.com/apache/dubbo-js/assets/79406469/219a311c-bbd5-4d6f-8dad-2c91c05164b0)
   
   
   
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to