Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to share the same web server port with user's application for transport module? #1565

Closed
dai19470 opened this issue Jun 23, 2020 · 7 comments · Fixed by #1957
Closed
Labels
area/integrations Issues or PRs related to integrations with open-source components good first issue Good for newcomers kind/discussion For further discussion

Comments

@dai19470
Copy link

springboot项目集成使用sentinel后部署到docker容器里.但是docker对外只提供一个端口给web使用.请教一下.在不对外提供端口的情况下(默认8719),dashboard和使用sentinel的客户端怎么保持心跳?

@cdfive
Copy link
Collaborator

cdfive commented Jun 23, 2020

目前使用了sentinel的应用端是通过独立的HTTP端口(默认8719)和dashboard交互的,因为应用端可能没有使用spring/springboot,也可能不是web应用。如果使用了springboot web,想仅使用一个端口,目前是不支持的。

是否需要共用一个web端口以及如何支持欢迎一起讨论哈~
cc @sczyh30 @jasonjoo2010

@cdfive cdfive added area/integrations Issues or PRs related to integrations with open-source components kind/discussion For further discussion labels Jun 23, 2020
@dai19470
Copy link
Author

dai19470 commented Jun 28, 2020

您好,我的解决方案是共用一个web端口:

  1. 不使用sentinel-tranport下面的模块.自己增加定时任务向dashboard的路径/registry/machine 发送心跳数据,配置ip和port为springboot(sentinel应用端)web的ip和端口,
    image

  2. 参照sentinel-transport-common下com.alibaba.csp.sentinel.command.handler.一一对应在springboot的项目(sentinel应用端口)增加controller.如下图
    image
    image

3.建议在sentinel-transport下面增加模块sentinel-transport-web,将上述内容统一到这个模块里.建议修改sentinel-transport-common为工具类模块. sentinel-transport-web或sentinel-transport-simple-http调用common中的方法.

@sczyh30 sczyh30 changed the title 项目集成sentinel部署到docker中.端口问题 How to share the same web server port with user's application for transport module? Jun 29, 2020
@jasonjoo2010
Copy link
Collaborator

If it really matters i have another idea that,

  1. Introduce a new configuration defining the prefix of path to hook in, for instance, transport-prefix
  2. Introduce new module, for instance, sentinel-transport-springboot, intercepting into springboot
  3. Introduce new module, for instance, sentinel-transport-servlet, providing SentinelTransportServlet to register
  4. Other frameworks adaption.

Follow the sentinel way: Introduce what you want and you have.

@dai19470
Copy link
Author

dai19470 commented Jul 1, 2020

@jasonjoo2010 Yeah! i used like your idea :
image
my code is based on official Sentinel for secondary development, and has a big different with the official code,so if share my code that is of small significance(我的代码是基于官方代码二次开发的,和官方代码差别很大,所以贡献出来没有多大意义,可以的话联系我提供一个通用的,为sentinel贡献一份力量)

@jasonjoo2010
Copy link
Collaborator

@sczyh30 @cdfive so what do you think about it?

If it's worthy we should make it agile because here's a nearly completed implementation of them.

@shenbaoyong
Copy link
Contributor

I have a idea, I create a new module named sentinel-transport-spring-mvc, implements tow interfaces of spring-mvc(SentinelApiHandlerAdapter-HandlerAdapter SentinelApiHandlerMapping-HandlerMapping), mapping the api of dashboard want to visit to SentinelApiHandler(CommandHandler). In this way, we no need update the existing module.
(我有一个想法,我新加了一个模块sentinel-transport-spring-mvc,实现spring-mvc里面的HandlerAdapter和HandlerMapping,把控制台需要访问的接口映射到CommandHandler。这样不需要改动已有的模块,CommandHandler的逻辑也不需要重新实现一遍)

@cdfive
Copy link
Collaborator

cdfive commented Jan 15, 2021

@shenbaoyong Good idea! It really solved the problem.

@sczyh30 sczyh30 added the good first issue Good for newcomers label Jan 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/integrations Issues or PRs related to integrations with open-source components good first issue Good for newcomers kind/discussion For further discussion
Projects
None yet
5 participants