You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shenyu.apache.org by "topcatv (via GitHub)" <gi...@apache.org> on 2024/08/01 05:48:55 UTC

[I] [Question] I want the host registered with the gateway to be the hostname that I specify. How can I achieve this? [shenyu]

topcatv opened a new issue, #5601:
URL: https://github.com/apache/shenyu/issues/5601

   ### Question
   
   When using shenyu-spring-boot-starter-client-springmvc, I want the host registered with the gateway to be the hostname that I specify. How can I achieve this?
   Because I used the service in k8s to provide services, therefore I used the following configuration in the configuration file.
   ```yaml
   shenyu:
     register:
       registerType: http
       serverLists: http://shenyu-admin-svc:9095
       props:
         username: admin
         password: xxxxx
     client:
       http:
         props:
           host: biz-service
           contextPath: /biz
           appName: biz
   ```
   However, after registering to the gateway, it was found that the upstream of the divide was still the IP address of this service instead of the service name. Through source code analysis, it was found in the `org.apache.shenyu.client.springmvc.init.SpringMvcClientEventListener#buildURIRegisterDTO` method
   ```java
   try {
       return URIRegisterDTO.builder()
               .contextPath(getContextPath())
               .appName(getAppName())
               .protocol(protocol)
               .host(super.getHost())
               .port(Integer.valueOf(getPort()))
               .rpcType(RpcTypeEnum.HTTP.getName())
               .eventType(EventType.REGISTER)
               .build();
   } catch (ShenyuException e) {
       throw new ShenyuException(e.getMessage() + "please config ${shenyu.client.http.props.port} in xml/yml !");
   }
   ```
   
   ```java
   public String getHost() {
       return IpUtils.isCompleteHost(this.host) ? this.host
               : IpUtils.getHost(this.host);
   }
   ```
   `IpUtils.isCompleteHost(this.host)` returns false, so the host IP will be fetched. Can this be changed here to support configuring the host name or svc in k8s?


-- 
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@shenyu.apache.org.apache.org

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


Re: [I] [Question] I want the host registered with the gateway to be the hostname that I specify. How can I achieve this? [shenyu]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 commented on issue #5601:
URL: https://github.com/apache/shenyu/issues/5601#issuecomment-2262175515

   hi, the `IpUtils.isCompleteHost` method is for checking whether the host is complete, and it actually just support ip now 


-- 
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@shenyu.apache.org

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


Re: [I] [Question] I want the host registered with the gateway to be the hostname that I specify. How can I achieve this? [shenyu]

Posted by "Aias00 (via GitHub)" <gi...@apache.org>.
Aias00 commented on issue #5601:
URL: https://github.com/apache/shenyu/issues/5601#issuecomment-2268043234

   hi, we will discuss thia problem later, and may solve this problem in next version 


-- 
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@shenyu.apache.org

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


Re: [I] [Question] I want the host registered with the gateway to be the hostname that I specify. How can I achieve this? [shenyu]

Posted by "x519286925 (via GitHub)" <gi...@apache.org>.
x519286925 commented on issue #5601:
URL: https://github.com/apache/shenyu/issues/5601#issuecomment-2268038518

   > Whether to consider supporting hostname or service name of k8s service
   
   我也发现了这个问题,然后我用多语言的http客户端用调接口的方式倒可以用hostname,不知道是设计问题还是什么,也能实现正常转发
   https://shenyu.apache.org/zh/docs/developer/developer-shenyu-client
   
   I also discovered this issue, and then I used a multilingual HTTP client to call the interface using hostname. I don't know if it's a design problem or something, but I can still achieve normal forwarding
   
   😄


-- 
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@shenyu.apache.org

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


Re: [I] [Question] I want the host registered with the gateway to be the hostname that I specify. How can I achieve this? [shenyu]

Posted by "topcatv (via GitHub)" <gi...@apache.org>.
topcatv commented on issue #5601:
URL: https://github.com/apache/shenyu/issues/5601#issuecomment-2264941408

   Whether to consider supporting hostname or service name of k8s 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@shenyu.apache.org

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


Re: [I] [Question] I want the host registered with the gateway to be the hostname that I specify. How can I achieve this? [shenyu]

Posted by "yu199195 (via GitHub)" <gi...@apache.org>.
yu199195 closed issue #5601: [Question] I want the host registered with the gateway to be the hostname that I specify. How can I achieve this?
URL: https://github.com/apache/shenyu/issues/5601


-- 
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@shenyu.apache.org

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