关于公共服务和Biz服务分离开发的问题

Blade 未结 2 446
med
med 剑圣 2023-06-01 11:55

一、该问题的重现步骤是什么?

  1. 我现在将公共服务部署在服务器上,biz服务跑在本地、gateway也跑在本地,但是当我调用服务器上的公共服务时,报500错误;nacos上所有的服务注册的也没问题,本地和服务器可以ping通


  2. image.png

2. image.png

3.image.png


image.png

二、你期待的结果是什么?实际看到的又是什么?


三、你正在使用的是什么产品,什么版本?在什么操作系统上?

2.9.1商业版。windows

四、请提供详细的错误堆栈信息,这很重要。


五、若有更多详细信息,请在下面提供。

2条回答
  • 这个错的具体内容贴一下。

    image.png

    作者追问:2023-06-01 11:59

    2023-06-01 11:46:10.922 ERROR 37436 --- [ctor-http-nio-3] o.s.w.s.adapter.HttpWebHandlerAdapter    : [81f8b5bd-1] 500 Server Error for HTTP GET "/blade-system/tenant/info?domain=http:%2F%2Flocalhost:8566"


    java.lang.NullPointerException: null

    at org.springblade.gateway.handler.ErrorExceptionHandler.getHttpStatus(ErrorExceptionHandler.java:76) ~[classes/:na]

    at org.springframework.boot.autoconfigure.web.reactive.error.DefaultErrorWebExceptionHandler.renderErrorResponse(DefaultErrorWebExceptionHandler.java:146) ~[spring-boot-autoconfigure-2.3.12.RELEASE.jar:2.3.12.RELEASE]

    at org.springframework.boot.autoconfigure.web.reactive.error.AbstractErrorWebExceptionHandler.lambda$handle$0(AbstractErrorWebExceptionHandler.java:304) ~[spring-boot-autoconfigure-2.3.12.RELEASE.jar:2.3.12.RELEASE]

    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onNext(MonoFlatMap.java:118) [reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxSwitchIfEmpty$SwitchIfEmptySubscriber.onNext(FluxSwitchIfEmpty.java:67) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.Operators$ScalarSubscription.request(Operators.java:2393) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.set(Operators.java:2190) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.Operators$MultiSubscriptionSubscriber.onSubscribe(Operators.java:2064) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoJust.subscribe(MonoJust.java:54) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.Mono.subscribe(Mono.java:4252) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:97) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:100) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onError(FluxOnAssembly.java:390) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.Operators.error(Operators.java:196) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoError.subscribe(MonoError.java:52) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.Mono.subscribe(Mono.java:4252) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxOnErrorResume$ResumeSubscriber.onError(FluxOnErrorResume.java:97) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onError(FluxOnAssembly.java:390) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onError(MonoPeekTerminal.java:251) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onError(MonoPeekTerminal.java:251) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onError(FluxOnAssembly.java:390) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxOnAssembly$OnAssemblySubscriber.onError(FluxOnAssembly.java:390) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoFlatMap$FlatMapMain.onError(MonoFlatMap.java:165) [reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoFlatMap$FlatMapMain.secondError(MonoFlatMap.java:185) [reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoFlatMap$FlatMapInner.onError(MonoFlatMap.java:251) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onError(MonoIgnoreThen.java:268) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onError(MonoIgnoreThen.java:268) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxDoFinally$DoFinallySubscriber.onError(FluxDoFinally.java:129) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxPeek$PeekSubscriber.onError(FluxPeek.java:214) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onError(MonoIgnoreThen.java:268) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onError(MonoPeekTerminal.java:251) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onError(MonoPeekTerminal.java:251) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoPeekTerminal$MonoTerminalPeekSubscriber.onError(MonoPeekTerminal.java:251) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoIgnoreThen$ThenIgnoreMain.onError(MonoIgnoreThen.java:268) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoFlatMapMany$FlatMapManyMain.onError(MonoFlatMapMany.java:197) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.SerializedSubscriber.onError(SerializedSubscriber.java:124) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxRetryWhen$RetryWhenMainSubscriber.whenError(FluxRetryWhen.java:213) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxRetryWhen$RetryWhenOtherSubscriber.onError(FluxRetryWhen.java:255) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.drain(FluxConcatMap.java:406) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxConcatMap$ConcatMapImmediate.onNext(FluxConcatMap.java:243) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.DirectProcessor$DirectInner.onNext(DirectProcessor.java:339) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.DirectProcessor.onNext(DirectProcessor.java:148) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.SerializedSubscriber.onNext(SerializedSubscriber.java:99) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.FluxRetryWhen$RetryWhenMainSubscriber.onError(FluxRetryWhen.java:180) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoCreate$DefaultMonoSink.error(MonoCreate.java:185) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.netty.http.client.HttpClientConnect$MonoHttpConnect$TcpClientSubscriber.onError(HttpClientConnect.java:353) ~[reactor-netty-0.9.20.RELEASE.jar:0.9.20.RELEASE]

    at reactor.core.publisher.MonoCreate$DefaultMonoSink.error(MonoCreate.java:185) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.netty.resources.PooledConnectionProvider$DisposableAcquire.onError(PooledConnectionProvider.java:523) ~[reactor-netty-0.9.20.RELEASE.jar:0.9.20.RELEASE]

    at reactor.netty.internal.shaded.reactor.pool.AbstractPool$Borrower.fail(AbstractPool.java:444) ~[reactor-netty-0.9.20.RELEASE.jar:0.9.20.RELEASE]

    at reactor.netty.internal.shaded.reactor.pool.SimpleDequePool.lambda$drainLoop$9(SimpleDequePool.java:399) ~[reactor-netty-0.9.20.RELEASE.jar:0.9.20.RELEASE]

    at reactor.core.publisher.FluxDoOnEach$DoOnEachSubscriber.onError(FluxDoOnEach.java:172) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.core.publisher.MonoCreate$DefaultMonoSink.error(MonoCreate.java:185) ~[reactor-core-3.3.17.RELEASE.jar:3.3.17.RELEASE]

    at reactor.netty.resources.PooledConnectionProvider$PooledConnectionAllocator$PooledConnectionInitializer.operationComplete(PooledConnectionProvider.java:304) ~[reactor-netty-0.9.20.RELEASE.jar:0.9.20.RELEASE]

    at reactor.netty.resources.PooledConnectionProvider$PooledConnectionAllocator$PooledConnectionInitializer.operationComplete(PooledConnectionProvider.java:254) ~[reactor-netty-0.9.20.RELEASE.jar:0.9.20.RELEASE]

    at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:578) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:571) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:550) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:491) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.util.concurrent.DefaultPromise.setValue0(DefaultPromise.java:616) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.util.concurrent.DefaultPromise.setFailure0(DefaultPromise.java:609) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:117) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:321) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:337) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:707) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493) ~[netty-transport-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]

    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[netty-common-4.1.65.Final.jar:4.1.65.Final]

    at java.lang.Thread.run(Thread.java:748) ~[na:1.8.0_131]


    0 讨论(0)
  • 2023-06-01 12:10

    你先把所有服务部署到服务器,看看能不能跑通。

    全部跑通的前提,再开启本地的服务gateway+服务进行本地调试,具体见文档 5.19章节 团队协作自定义负载配置

    作者追问:2023-06-01 13:28

    1、所有服务部署到服务器可以跑通(我预生产环境已经稳定运行2年)

    2、按照团队协作文档进行配置无效,仍然报500错误,我看之前群里也有人问这个问题,请正面回答将此问题处理掉!!!

    回答: 2023-06-01 13:40

    什么才叫正面回答?帖子描述的不够,我们光靠猜么?想让我们解决问题那你也要先把问题都描述完整才行哦。比如你本地负载是怎么配置的,配置文件截图是什么,本机与服务器ping通的截图,每个服务注册到nacos的ip是什么,注册上去的服务对应端口有没有开通,光ping通ip但端口不开也是没用的。

    不是光几个简单的描述和局部的截图就能帮你们解决问题,你说看到群里有人没成功,但我们看到的更多是成功的例子。

    如果你实在解决不了或者不知道怎么描述问题,请把部署的测试环境对外开放,并把地址发给我们邮件,我们安排调试:bladejava@qq.com

    作者追问:2023-06-01 14:12

    1、本地负载配置以及截图如下

    image.png

    2、本地与服务器ping通截图

    image.png

    3、每个服务注册到nacos上的IP

    image.png


    image.png

    image.png

    4、服务器上开通的端口为8848、9848、9849,至于您说的【注册上去的服务对应端口有没有开通,光ping通ip但端口不开也是没用的】,我不清楚还需要开通什么端口,我看原来的帖子并未提及开通端口

    image.png

    上述如果描述不够清楚的话,我可以发想你发测试环境地址!

    回答: 2023-06-01 14:52

    看下java服务的端口是否开通了,因为流程是先从本机的gateway调用到nacos,然后nacos返回服务的ip与端口,本机再去调用对应的ip+端口。

    如果服务端口没有开通,那么哪怕是ping通了,也是无法调用的。


    你先把这些端口都开通,让本机访问服务器上的服务+ip端口是否可以成功,接着再通过gateway调用,如果调试依旧不通过,麻烦把ip+端口开通至外网,然后发一封邮件,之后我们就可以开始帮你调试找问题了。

    image.png

    作者追问:2023-06-01 15:44

    外网端口已映射,邮件已发

    回答: 2023-06-01 15:48

    你要先理清楚nacos调用的逻辑。

     1. 本机把gateway注册到nacos

     2. 本地调用gateway,访问blade-system服务

     3. gateway去nacos获取blade-system服务的注册地址端口,比如 10.x.x.10:8106

     4. gateway把 localhost/blade-system/user/list 转换成 10.x.x.10:8106/user/list

     5. 那问题就在于你本地能不能访问到 10.x.x.10:8106/user/list

     6. 你现在把8106端口改成38106给我们,我们调用还是会访问 10.x.x.10:8106/user/list,依旧不通

     7. 所以需要你把什么端口注册到nacos,就映射出一样的端口才行

     8. 这样本机才能通过gateway去nacos获取远程服务地址,再调用成功

     

    0 讨论(0)
提交回复