You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2022/11/17 08:07:03 UTC

[GitHub] [dubbo] wxbty opened a new issue, #10950: Dubbo lacks extensions for exceptions

wxbty opened a new issue, #10950:
URL: https://github.com/apache/dubbo/issues/10950

   We are working on a dubbo gateway and need to support mutual access between different network clusters. This should be a common scenario. This requires dubbo to do two things for us:
   
   1. Dynamically modify the ip and change the access of the local cluster to remote. This extension can be done, although there are some bugs, https://dubbo.apache.org/zh/docs3-v2/java-sdk/advanced-features-and-usage/service/specify-ip/
   
   2. Forward the dubbo request. When the gateway receives the access request from cluster A, it should forward it to cluster B (now it returns an exception).
     From the code execution process.
   
     current:
     gateway-dubbo-provider receives the request -> parses -> judges whether the request interface has a corresponding cache URL -> no -> throws IOException -> netty returns
   
     ```java
     void handleRequest(final ExchangeChannel channel, Request req) throws RemotingException {
             Response res = new Response(req.getId(), req.getVersion());
             if (req.isBroken()) {
                 Object data = req.getData();
                 String msg;
                 if (data == null) {
                     msg = null;
                 } else if (data instanceof Throwable) {
                     msg = StringUtils.toString((Throwable) data);
                 } else {
                     msg = data.toString();
                 }
                 res.setErrorMessage("Fail to decode request due to: " + msg);
                 res.setStatus(Response.BAD_REQUEST);
   
                 channel.send(res);
                 return;
             }
     }
     ```
   
     ​
   
     expect:
     gateway-dubbo-provider receives the request -> parses -> judges whether the request interface has a corresponding cache URL -> no -> obtains the exception handler through spi (the request can be forwarded here) -> netty returns
   
   ```java
     void handleRequest(final ExchangeChannel channel, Request req) throws RemotingException {
             Response res = new Response(req.getId(), req.getVersion());
             if (req.isBroken()) {
                 Object data = req.getData();
              //expert begin
             List<ExceptionHandler> list = spiExtensions.listByType(ExceptionHandler); 
             list.forEach(handler.handle(path,version))
              //expert end
                 String msg;
                 if (data == null) {
                     msg = null;
                 } else if (data instanceof Throwable) {
                     msg = StringUtils.toString((Throwable) data);
                 } else {
                     msg = data.toString();
                 }
                 res.setErrorMessage("Fail to decode request due to: " + msg);
                 res.setStatus(Response.BAD_REQUEST);
   
                 channel.send(res);
                 return;
             }
     }
   ```
   
   
   Since dubbo.extension provides dynamic ip replacement, then we should consider whether the target ip can be accepted and processed. I think this exception handler is an extension function of the dubbo.extension package.
   We can provide ExceptionHandler similar to springboot, which can be more flexible
   


-- 
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: notifications-unsubscribe@dubbo.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1319449119

   It is not recommend to forward a request in filter.
   
   It is more recommended to export a gerenic impl service, and in this service request the upstream with ip specification in gerenic mode.
   
   https://dubbo.apache.org/zh/docs3-v2/java-sdk/advanced-features-and-usage/service/generic-reference/
   https://dubbo.apache.org/zh/docs3-v2/java-sdk/advanced-features-and-usage/service/generic-service/


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1321515455

   > Yes, maybe server-side generalization is a good idea
   
   This should be carefully considered, as there may be potential risks of DoS and RCE.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wxbty commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
wxbty commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1321492900

   Yes, maybe server-side generalization is a good idea


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1328421314

   > The second is that DecodeableRpcInvocation still throws a service not found exception, try to catch this exception externally, and then perform custom behavior.
   
   At present, this method is more practical.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wxbty commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
wxbty commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1327321346

   Which did you decide to use? I've implemented server-side generalization test  works


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wxbty commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
wxbty commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1321405614

   In my fork branch, I try to add a more general generalization service with the following code.
   OmnService  is similar to  GenericService 
   
   ```java
   public static void checkSerialization(FrameworkServiceRepository serviceRepository, String path, String version, Byte id) throws IOException {
       List<URL> urls = serviceRepository.lookupRegisteredProviderUrlsWithoutGroup(keyWithoutGroup(path, version));
       if (CollectionUtils.isEmpty(urls)) {
           //尝试通用service
           urls = serviceRepository.lookupRegisteredProviderUrlsWithoutGroup("org.apache.dubbo.rpc.service.OmnService:0.0.0");
       }
       if (CollectionUtils.isEmpty(urls)) {
           throw new IOException("Service " + path + " with version " + version + " not found, invocation rejected.");
       } else {
   ...
   ```


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wxbty commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
wxbty commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1326134138

   The first way doesn't look intuitive at the design level.
   
   Exception handling is a common practice, which will interrupt the original execution process, which means a large modification. If decide to join this mechanism, it is a good choice.
   
   The third is not very understandable, it seems that a separate stage is added to the life cycle?
   
   Then how about server-side generalization,maybe minimal changes,intuitive by design? the current server-side generalization does not seem to be useful.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1321390958

   The gateway itself should have the way to know which services it should proxyes with. In thus, the gateway can export those services into a special registry, which is provided to upstream. (Or if local export is acceptable, set scope field in reference config as `remote`.)


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wxbty commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
wxbty commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1321401483

   I can solve this problem through some other methods, such as dynamically modifying the ip, and modifying the interface information to an agreed fixed interface at the same time, so that the dubbo gateway can register the same provider and receive it. As for the subsequent forwarding, get it from the parameters and then reflect Just call. But I don't think it should, because in fact it's a 404 extension that dubbo is missing. springmvc can be customized through ErrorController, dubbo should also be able to, 404 is also a part of the life cycle. This is also the reason why I raised issue in dubbo


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ closed issue #10950: Dubbo lacks extensions for exceptions

Posted by "AlbumenJ (via GitHub)" <gi...@apache.org>.
AlbumenJ closed issue #10950: Dubbo lacks extensions for exceptions
URL: https://github.com/apache/dubbo/issues/10950


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wxbty commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
wxbty commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1321551265

   Security issues do need to be considered, but I understand that dubbo is an internal service, even if it is on the external network, we can also verify it through the whitelist. If there is a discussion result, please let me implement it


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1326072790

   > Security issues do need to be considered, but I understand that dubbo is an internal service, even if it is on the external network, we can also verify it through the whitelist. If there is a discussion result, please let me implement it
   
   There are three ways to solve this problem.
   The first one is to directly generate an invocation according to a specific format when the service cannot be found in DecodeableRpcInvocation. Then implement service forwarding in Filter or other places that can be intercepted.
   The second is that DecodeableRpcInvocation still throws a service not found exception, try to catch this exception externally, and then perform custom behavior.
   The third is to split DecodeableRpcInvocation, first identify the path and method, and then process the logic of the request first. At this time, it can be forwarded, and then enter the original implementation after the first processing.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1327152360

   > The third is not very understandable, it seems that a separate stage is added to the life cycle?
   
   Yep. Separate `DecodeableRpcInvocation` into several stages. First, decode path. Second, check if path exist. Third, decode body.
   
   > the current server-side generalization does not seem to be useful.
   
   Generic impl should be handled separatly. The process of service not found exception could be reused with `DecodeableRpcInvocation`.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] wxbty commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
wxbty commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1319659765

   @AlbumenJ 
   After testing, the generalization of the server needs to fill in the same interface name as the consumer. Otherwise, the checkSerialization method in CodecSupport will be intercepted and an exception will be returned to the consumer without any extension point.
   
   ```java
   // 该实例很重量,里面封装了所有与注册中心及服务提供方连接,请缓存 
   ServiceConfig<GenericService> service = new ServiceConfig<GenericService>();
   // 弱类型接口名 
   service.setInterface("com.xxx.XxxService");  //-----------这里限制了任意接口的访问  
   service.setVersion("1.0.0"); 
   // 指向一个通用服务实现 
   service.setRef(xxxService); 
   ```
   
   What I expect is that the server can accept any interface name and method, and then customize the return content.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] AlbumenJ commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by GitBox <gi...@apache.org>.
AlbumenJ commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1321439988

   org/apache/dubbo/rpc/protocol/dubbo/DecodeableRpcInvocation.java:208
   org.apache.dubbo.remoting.transport.CodecSupport#checkSerialization
   
   Do you mean that you need to customized the actions if a service is not found?


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] mytang0 commented on issue #10950: Dubbo lacks extensions for exceptions

Posted by "mytang0 (via GitHub)" <gi...@apache.org>.
mytang0 commented on issue #10950:
URL: https://github.com/apache/dubbo/issues/10950#issuecomment-1434169785

   It is true that multi-cloud and hybrid cloud are becoming a trend, and cross-cloud facilities are becoming more and more important. After reading your previous discussions, I feel that a discussion can be initiated: it would be better to build a separate module dubbo-bridge to realize cross-cloud functions.


-- 
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: notifications-unsubscribe@dubbo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org