shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

[Question] <shenyu can't recognize random port>

Open IcebergXTY opened this issue 2 years ago • 5 comments

Question

when we use microservice architecture, the port is unimportant, so we always use 0(server.port)or -1(dubbo.protocol.port)to use a random port. But shenyu will just use 0 and -1 when running. Is there any way to get it to the actual port? Or must I use a fix port when I use shenyu?

IcebergXTY avatar Apr 20 '23 08:04 IcebergXTY

I don't understand what you mean at all?

whats shenyu version? What features do you use it for?

yu199195 avatar Apr 20 '23 09:04 yu199195

@yu199195 I upload a demo. I use random tomcat port(set server.port=0) and random dubbo port(set dubbo.protocol.port=-1), tomcat and dubbo will use a random usable port, but shenyu will print error log like below

2023-04-21 10:10:41.431  INFO 54360 --- [           main] o.a.d.config.bootstrap.DubboBootstrap    :  [DUBBO] DubboBootstrap has started., dubbo version: 2.7.17, current host: 10.60.52.17
Exception in thread "shenyu-disruptor-shenyu_disruptor_consumer_-97" java.lang.IllegalArgumentException: port out of range:-1
	at java.net.InetSocketAddress.checkPort(InetSocketAddress.java:143)
	at java.net.InetSocketAddress.<init>(InetSocketAddress.java:224)
	at java.net.Socket.<init>(Socket.java:229)
	at org.apache.shenyu.client.core.disruptor.subcriber.ShenyuClientURIExecutorSubscriber.executor(ShenyuClientURIExecutorSubscriber.java:62)
	at org.apache.shenyu.client.core.disruptor.executor.RegisterClientConsumerExecutor.run(RegisterClientConsumerExecutor.java:45)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:750)
2023-04-21 10:10:42.846  INFO 54360 --- [or_consumer_-99] .r.c.z.ZookeeperClientRegisterRepository : dubbo zookeeper client register metadata success: MetaDataRegisterDTO{appName='shenyu-demo, contextPath='/dubbo, path='/dubbo/hello/sayHello, pathDesc=', rpcType='dubbo, serviceName='com.iceberg.rh.rhf.yqs.saas.shenyu.api.HelloService, methodName='sayHello, ruleName='/dubbo/hello/sayHello, parameterTypes='java.lang.String, rpcExt='{"loadbalance":"random","retries":2,"timeout":3000,"sent":false,"cluster":"failover","protocol":"dubbo"}, enabled=true, host='10.60.52.17, port=-1, pluginNames=[], registerMetaData=false, timeMillis=1682043042832, addPrefixed=false}
2023-04-21 10:10:43.599  INFO 54360 --- [r_consumer_-104] .r.c.z.ZookeeperClientRegisterRepository : websocket zookeeper client register metadata success: MetaDataRegisterDTO{appName='shenyu-demo, contextPath='/ws-annotation, path='/ws-annotation/, pathDesc='null, rpcType='websocket, serviceName='null, methodName='null, ruleName='/ws-annotation, parameterTypes='null, rpcExt='null, enabled=true, host='null, port=null, pluginNames=[], registerMetaData=false, timeMillis=1682043043589, addPrefixed=false}
2023-04-21 10:10:44.336  INFO 54360 --- [r_consumer_-110] .r.c.z.ZookeeperClientRegisterRepository : http zookeeper client register metadata success: MetaDataRegisterDTO{appName='shenyu-demo, contextPath='/http, path='/http/ws/**, pathDesc=', rpcType='http, serviceName='com.iceberg.rh.rhf.yqs.saas.shenyu.websocket.TestHttpController, methodName='null, ruleName='/http/ws/**, parameterTypes='null, rpcExt='null, enabled=true, host='null, port=null, pluginNames=[], registerMetaData=true, timeMillis=1682043044331, addPrefixed=false}
2023-04-21 10:10:44.339  INFO 54360 --- [           main] c.i.r.r.y.s.s.ShenyyDemoApplication      : Started ShenyyDemoApplication in 11.239 seconds (JVM running for 12.968)
2023-04-21 10:10:45.817  INFO 54360 --- [(3)-10.60.52.17] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-04-21 10:10:45.817  INFO 54360 --- [(3)-10.60.52.17] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2023-04-21 10:10:45.818  INFO 54360 --- [(3)-10.60.52.17] o.s.web.servlet.DispatcherServlet        : Completed initialization in 1 ms
2023-04-21 10:10:49.660 ERROR 54360 --- [r_consumer_-100] .c.d.s.ShenyuClientURIExecutorSubscriber : host:10.60.52.17, port:0 connection failed, will retry
2023-04-21 10:10:50.388 ERROR 54360 --- [r_consumer_-109] .c.d.s.ShenyuClientURIExecutorSubscriber : host:10.60.52.17, port:0 connection failed, will retry
2023-04-21 10:10:50.667 ERROR 54360 --- [r_consumer_-100] .c.d.s.ShenyuClientURIExecutorSubscriber : host:10.60.52.17, port:0 connection failed, will retry
2023-04-21 10:10:51.395 ERROR 54360 --- [r_consumer_-109] .c.d.s.ShenyuClientURIExecutorSubscriber : host:10.60.52.17, port:0 connection failed, will retry
2023-04-21 10:10:51.674 ERROR 54360 --- [r_consumer_-100] .c.d.s.ShenyuClientURIExecutorSubscriber : host:10.60.52.17, port:0 connection failed, will retry
2023-04-21 10:10:52.402 ERROR 54360 --- [r_consumer_-109] .c.d.s.ShenyuClientURIExecutorSubscriber : host:10.60.52.17, port:0 connection failed, will retry
2023-04-21 10:10:52.681 ERROR 54360 --- [r_consumer_-100] .c.d.s.ShenyuClientURIExecutorSubscriber : host:10.60.52.17, port:0 connection failed, will retry
2023-04-21 10:10:53.412 ERROR 54360 --- [r_consumer_-109] .c.d.s.ShenyuClientURIExecutorSubscriber : host:10.60.52.17, port:0 connection failed, will retry
2023-04-21 10:10:53.694 ERROR 54360 --- [r_consumer_-100] .c.d.s.ShenyuClientURIExecutorSubscriber : host:10.60.52.17, port:0 connection failed, will retry

IcebergXTY avatar Apr 21 '23 02:04 IcebergXTY

whats shenyu version? in now used this function:

final int mergedPort = port <= 0 ? PortUtils.findPort(event.getApplicationContext().getAutowireCapableBeanFactory()) : port;

yu199195 avatar Apr 21 '23 03:04 yu199195

whats shenyu version? in now used this function:

final int mergedPort = port <= 0 ? PortUtils.findPort(event.getApplicationContext().getAutowireCapableBeanFactory()) : port;

I use version 2.5.1 but it seems dosen't work. image

IcebergXTY avatar Apr 21 '23 03:04 IcebergXTY

whats shenyu version? in now used this function:

final int mergedPort = port <= 0 ? PortUtils.findPort(event.getApplicationContext().getAutowireCapableBeanFactory()) : port;

I use version 2.5.1 but it seems dosen't work. image

I have the same problem. How can I solve it

HeiXXwowoTou avatar May 25 '23 06:05 HeiXXwowoTou