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/06/15 02:59:47 UTC

[GitHub] [dubbo] ldkjdk opened a new issue, #10159: Implove dubbo-rpc-http

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

   ## Describe the feature
   <!-- Please also discuss possible business value -->
   
   Implove dubbo-rpc-http for http , and support the https  protocol , example
   <dubbo:reference version="3.0.0" id="thirdPartyProductService"   interface="com.xxxxx.ThirdPartyProductService" url="https://testdubbo.ddky.com" timeout="60000" />
   
   for mixed cloud deploy , hisroty system of the  base dubbo rpc  transferto public cloud, we are will take fllow architect
   public cloud consumer->https://xxxxxxx-> nginx-> private dubbo http service provider 
   But have lot of bug , example for jackson serialize issue
   follow is we fixed :
   1. jsonrpc4j version update to 1.5.3 by pom dependency
   2. update HttpProtocol code 
   3.  add resources/META-INF/services/org.apache.dubbo.rpc.Protocol file and add  conteht to file http=org.apache.dubbo.rpc.protocol.http.HttpsProtocol
   https=org.apache.dubbo.rpc.protocol.http.HttpsProtocolco
   4. changes
   @SuppressWarnings("unchecked")
       @Override
       protected <T> T doRefer(final Class<T> serviceType, URL url) throws RpcException {
           final String generic = url.getParameter(GENERIC_KEY);
           final boolean isGeneric = ProtocolUtils.isGeneric(generic) || serviceType.equals(GenericService.class);
           JsonProxyFactoryBean jsonProxyFactoryBean = new JsonProxyFactoryBean();
           JsonRpcProxyFactoryBean jsonRpcProxyFactoryBean = new JsonRpcProxyFactoryBean(jsonProxyFactoryBean);
           jsonRpcProxyFactoryBean.setRemoteInvocationFactory((methodInvocation) -> {
               RemoteInvocation invocation = new JsonRemoteInvocation(methodInvocation);
               if (isGeneric) {
                   invocation.addAttribute(GENERIC_KEY, generic);
               }
               return invocation;
           });
           String key = url.setProtocol("http").toIdentityString();
           if (isGeneric) {
               key = key + "/" + GENERIC_KEY;
           }
   
           jsonRpcProxyFactoryBean.setServiceUrl(key);
           jsonRpcProxyFactoryBean.setServiceInterface(serviceType);
   
           ObjectMapper mapper = new ObjectMapper();
           //for fixed https://github.com/FasterXML/jackson/issues/106
           mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
           jsonProxyFactoryBean.setObjectMapper(mapper);
           
           try {
               boolean acceptGzipResponses = false;
               boolean gzipRequests = false;
               
               Map<String, String> extraHttpHeaders = new HashMap<>();
               // to get gizp properties heads properties
               acceptGzipResponses = url.getParameter(DdkyConstants.RESPONSE_GIZP, false);
               gzipRequests = url.getParameter(DdkyConstants.REQUEST_GIZP, false);
               
              for (Entry<String, String> e:url.getParameters().entrySet()) {
                  if (e.getKey().startsWith(DdkyConstants.HTTP_HEADER)) {
                       String k = e.getKey().substring(DdkyConstants.HTTP_HEADER.length());
                      extraHttpHeaders.put(k, e.getValue());
                  }
              }
               
              JsonRpcHttpClient jsonRpcHttpClient = 
                      new JsonRpcHttpClient(mapper, new java.net.URL(jsonProxyFactoryBean.getServiceUrl()), 
                              extraHttpHeaders,gzipRequests,acceptGzipResponses);
              //jsonRpcHttpClient.setRequestListener(jsonProxyFactoryBean.get);
              //jsonRpcHttpClient.setSslContext();
             //jsonRpcHttpClient.setHostNameVerifier(hostNameVerifier);
             String contentType = url.getParameter(DdkyConstants.HTTP_CONTENT_TYPE, "application/json-rpc");
             if (contentType != null) {
               jsonRpcHttpClient.setContentType(contentType);
             }
           
            // if (exceptionResolver!=null) {
             //  jsonRpcHttpClient.setExceptionResolver(exceptionResolver);
             // }
             
             
             
              jsonRpcHttpClient.setConnectionTimeoutMillis(url.getPositiveParameter(Constants.CONNECT_TIMEOUT_KEY, Constants.DEFAULT_CONNECT_TIMEOUT));
              jsonRpcHttpClient.setReadTimeoutMillis(url.getPositiveParameter(TIMEOUT_KEY, DEFAULT_TIMEOUT));
              jsonProxyFactoryBean.setJsonRpcHttpClient(jsonRpcHttpClient);
           } catch (Exception e) {
               throw new RuntimeException(e);
           
           }
           
           
           jsonProxyFactoryBean.afterPropertiesSet();
           return (T) jsonProxyFactoryBean.getObject();
       }
   


-- 
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 #10159: Implove dubbo-rpc-http

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

   would you please submit a pr to fix 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