iohao / ioGame

无锁异步化、事件驱动架构设计的 java netty 网络编程框架; 轻量级,无需依赖任何第三方中间件或数据库就能支持集群、分布式; 适用于网络游戏服务器、物联网、内部系统及各种需要长连接的场景; 通过 ioGame 你可以很容易的搭建出一个集群无中心节点、集群自动化、分布式的网络服务器;FXGL、Unity、UE、Cocos Creator、Godot、Netty、Protobuf、webSocket、tcp、socket;java Netty 游戏服务器框架;
http://game.iohao.com
GNU Affero General Public License v3.0
902 stars 200 forks source link

单机运行部署到服务器docker无法连接网关 #196

Closed zglbig closed 1 year ago

zglbig commented 1 year ago

单机启动 然后部署到docker容器中 在逻辑服中的

AbstractBrokerClientStartup.createBrokerClientBuilder() 

中的

 BrokerClientBuilder builder = BrokerClient.newBuilder();
        builder.brokerAddress(new BrokerAddress("远程服务器地址", IoGameGlobalConfig.brokerPort));
        builder.appName("123”)

和对外服中的

var builder = DefaultExternalServer
                // 游戏对外服端口;与真实玩家建立连接的端口
                .newBuilder(externalPort)
                // 连接方式 WebSocket;默认不填写也是这个值
                .externalJoinEnum(ExternalJoinEnum.WEBSOCKET)
                // 与 Broker (游戏网关)的连接地址 ;默认不填写也是这个值
                .brokerAddress(new BrokerAddress("远程服务地址", IoGameGlobalConfig.brokerPort));

都设置了远程的服务器地址,但是在运行的时候就出现

2023-09-14T11:15:29.102+08:00  INFO 1 --- [Bolt-conn-event-executor-9-thread-1] ConnectionTopic                          : 连接网关 ConnectionEventType:【CONNECT】 remoteAddress:【127.0.0.1:10200】,网关连接数量:【0】
2023-09-14T11:15:29.136+08:00  INFO 1 --- [Bolt-conn-event-executor-13-thread-1] ConnectionTopic                          : 连接网关 ConnectionEventType:【CONNECT】 remoteAddress:【172.17.0.3:10200】,Connection:【com.alipay.remoting.Connection@311158ff】
2023-09-14T11:15:29.141+08:00  INFO 1 --- [Bolt-conn-event-executor-13-thread-1] ConnectionTopic                          : 连接网关 ConnectionEventType:【CONNECT】 remoteAddress:【172.17.0.3:10200】,网关连接数量:【0】
2023-09-14T11:15:29.156+08:00  INFO 1 --- [Bolt-conn-event-executor-21-thread-1] ConnectionTopic                          : 连接网关 ConnectionEventType:【CONNECT】 remoteAddress:【172.17.0.3:10200】,Connection:【com.alipay.remoting.Connection@131b9aed】
2023-09-14T11:15:29.160+08:00  INFO 1 --- [Bolt-conn-event-executor-21-thread-1] ConnectionTopic                          : 连接网关 ConnectionEventType:【CONNECT】 remoteAddress:【172.17.0.3:10200】,网关连接数量:【0】

和在调用

 ExternalCommunicationKit.forcedOffline(1000);
和
UserIdSettingKit.settingUserId(ctx, 1000);

的时候出现了远程调用异常而且连的是127.0.0.1的地址

2023-09-14T11:16:39.245+08:00 ERROR 1 --- [Thread-9] estCollectExternalMessageBrokerProcessor : Rpc invocation timeout[responseCommand TIMEOUT]! the address is 127.0.0.1:46168

com.alipay.remoting.rpc.exception.InvokeTimeoutException: Rpc invocation timeout[responseCommand TIMEOUT]! the address is 127.0.0.1:46168
    at com.alipay.remoting.rpc.RpcResponseResolver.preProcess(RpcResponseResolver.java:83)
    at com.alipay.remoting.rpc.RpcResponseResolver.resolveResponseObject(RpcResponseResolver.java:54)
    at com.alipay.remoting.rpc.RpcRemoting.invokeSync(RpcRemoting.java:186)
    at com.alipay.remoting.rpc.RpcServerRemoting.invokeSync(RpcServerRemoting.java:67)
    at com.alipay.remoting.rpc.RpcRemoting.invokeSync(RpcRemoting.java:143)
    at com.alipay.remoting.rpc.RpcServer.invokeSync(RpcServer.java:638)
    at com.iohao.game.bolt.broker.server.balanced.region.BrokerClientProxy.invokeSync(BrokerClientProxy.java:96)
    at com.iohao.game.bolt.broker.server.processor.InnerModuleRequestCollectExternalMessageBrokerProcessor.lambda$listFuture$0(InnerModuleRequestCollectExternalMessageBrokerProcessor.java:91)
    at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
    at java.base/java.lang.Thread.run(Thread.java:833)

2023-09-14T11:16:39.240+08:00 ERROR 1 --- [逻辑线程-1-1] c.i.g.b.b.core.client.BrokerClientItem   : Rpc invocation timeout[responseCommand TIMEOUT]! the address is 172.17.0.3:10200

com.alipay.remoting.rpc.exception.InvokeTimeoutException: Rpc invocation timeout[responseCommand TIMEOUT]! the address is 172.17.0.3:10200
    at com.alipay.remoting.rpc.RpcResponseResolver.preProcess(RpcResponseResolver.java:83)
    at com.alipay.remoting.rpc.RpcResponseResolver.resolveResponseObject(RpcResponseResolver.java:54)
    at com.alipay.remoting.rpc.RpcRemoting.invokeSync(RpcRemoting.java:186)
    at com.alipay.remoting.rpc.RpcClient.invokeSync(RpcClient.java:253)
    at com.iohao.game.bolt.broker.core.client.BrokerClientItem.invokeSync(BrokerClientItem.java:113)
    at com.iohao.game.bolt.broker.core.client.BrokerClientItem.invokeSync(BrokerClientItem.java:117)
    at com.iohao.game.bolt.broker.core.client.BrokerClientItem.invokeExternalModuleCollectMessage(BrokerClientItem.java:223)
    at com.iohao.game.bolt.broker.core.client.BrokerClientItem.invokeExternalModuleCollectMessage(BrokerClientItem.java:217)
    at com.iohao.game.bolt.broker.client.kit.ExternalCommunicationKit.forcedOffline(ExternalCommunicationKit.java:71)
    at io.game.login.action.TokenCheckAction.tokenCheck(TokenCheckAction.java:76)
    at io.game.login.action.TokenCheckAction.logInTokenCheck(TokenCheckAction.java:38)
    at io.game.login.action.TokenCheckActionMethodAccess.invoke(Unknown Source)
    at com.iohao.game.action.skeleton.core.flow.interal.DefaultActionMethodInvoke.invoke(DefaultActionMethodInvoke.java:46)
    at com.iohao.game.action.skeleton.core.DefaultActionCommandFlowExecute.execute(DefaultActionCommandFlowExecute.java:62)
    at com.iohao.game.action.skeleton.core.ActionCommandHandler.handler(ActionCommandHandler.java:39)
    at com.iohao.game.action.skeleton.core.ActionCommandTryHandler.handler(ActionCommandTryHandler.java:42)
    at com.iohao.game.action.skeleton.core.BarSkeleton.handle(BarSkeleton.java:106)
    at io.game.orm.context.GameRequestMessageClientProcessorHook.lambda$processLogic$0(GameRequestMessageClientProcessorHook.java:38)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)

2023-09-14T11:16:39.253+08:00 DEBUG 1 --- [逻辑线程-1-1] c.i.g.b.b.client.kit.UserIdSettingKit    : 1 逻辑服 SettingUserIdMessage(userId=353285, userChannelId=0242acfffe110003-00000001-00000012-91a1433e9104c2f1-04a51bf6, headMetadata=HeadMetadata(userId=0, cmdMerge=65537, sourceClientId=638093017, endPointClientId=0, rpcCommandType=2, attachmentData=null, channelId=0242acfffe110003-00000001-00000012-91a1433e9104c2f1-04a51bf6, msgId=0, stick=2, bindingLogicServerIds=null, cacheCondition=0, other=null, withNo=0), startTime=1694661399253)
2023-09-14T11:16:42.280+08:00 ERROR 1 --- [Processor-Executor-common-1-1] .s.p.SettingUserIdMessageBrokerProcessor : Rpc invocation timeout[responseCommand TIMEOUT]! the address is 127.0.0.1:46168

com.alipay.remoting.rpc.exception.InvokeTimeoutException: Rpc invocation timeout[responseCommand TIMEOUT]! the address is 127.0.0.1:46168
    at com.alipay.remoting.rpc.RpcResponseResolver.preProcess(RpcResponseResolver.java:83)
    at com.alipay.remoting.rpc.RpcResponseResolver.resolveResponseObject(RpcResponseResolver.java:54)
    at com.alipay.remoting.rpc.RpcRemoting.invokeSync(RpcRemoting.java:186)
    at com.alipay.remoting.rpc.RpcServerRemoting.invokeSync(RpcServerRemoting.java:67)
    at com.alipay.remoting.rpc.RpcRemoting.invokeSync(RpcRemoting.java:143)
    at com.alipay.remoting.rpc.RpcServer.invokeSync(RpcServer.java:638)
    at com.iohao.game.bolt.broker.server.balanced.region.BrokerClientProxy.invokeSync(BrokerClientProxy.java:96)
    at com.iohao.game.bolt.broker.server.processor.SettingUserIdMessageBrokerProcessor.handleRequest(SettingUserIdMessageBrokerProcessor.java:66)
    at com.iohao.game.bolt.broker.server.processor.SettingUserIdMessageBrokerProcessor.handleRequest(SettingUserIdMessageBrokerProcessor.java:44)
    at com.alipay.remoting.rpc.protocol.RpcRequestProcessor.dispatchToUserProcessor(RpcRequestProcessor.java:235)
    at com.alipay.remoting.rpc.protocol.RpcRequestProcessor.doProcess(RpcRequestProcessor.java:146)
    at com.alipay.remoting.rpc.protocol.RpcRequestProcessor$ProcessTask.run(RpcRequestProcessor.java:393)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:833)

2023-09-14T11:16:42.285+08:00 ERROR 1 --- [逻辑线程-1-1] c.i.g.b.b.client.kit.UserIdSettingKit    : Rpc invocation timeout[responseCommand TIMEOUT]! the address is 172.17.0.3:10200

com.alipay.remoting.rpc.exception.InvokeTimeoutException: Rpc invocation timeout[responseCommand TIMEOUT]! the address is 172.17.0.3:10200
    at com.alipay.remoting.rpc.RpcResponseResolver.preProcess(RpcResponseResolver.java:83)
    at com.alipay.remoting.rpc.RpcResponseResolver.resolveResponseObject(RpcResponseResolver.java:54)
    at com.alipay.remoting.rpc.RpcRemoting.invokeSync(RpcRemoting.java:186)
    at com.alipay.remoting.rpc.RpcClient.invokeSync(RpcClient.java:253)
    at com.iohao.game.bolt.broker.core.client.BrokerClientItem.invokeSync(BrokerClientItem.java:113)
    at com.iohao.game.bolt.broker.core.client.BrokerClient.invokeSync(BrokerClient.java:156)
    at com.iohao.game.bolt.broker.core.client.BrokerClient.invokeSync(BrokerClient.java:160)
    at com.iohao.game.bolt.broker.client.kit.UserIdSettingKit.settingUserId(UserIdSettingKit.java:83)
    at io.game.login.action.TokenCheckAction.tokenCheck(TokenCheckAction.java:80)
    at io.game.login.action.TokenCheckAction.logInTokenCheck(TokenCheckAction.java:38)
    at io.game.login.action.TokenCheckActionMethodAccess.invoke(Unknown Source)
    at com.iohao.game.action.skeleton.core.flow.interal.DefaultActionMethodInvoke.invoke(DefaultActionMethodInvoke.java:46)
    at com.iohao.game.action.skeleton.core.DefaultActionCommandFlowExecute.execute(DefaultActionCommandFlowExecute.java:62)
    at com.iohao.game.action.skeleton.core.ActionCommandHandler.handler(ActionCommandHandler.java:39)
    at com.iohao.game.action.skeleton.core.ActionCommandTryHandler.handler(ActionCommandTryHandler.java:42)
    at com.iohao.game.action.skeleton.core.BarSkeleton.handle(BarSkeleton.java:106)
    at io.game.orm.context.GameRequestMessageClientProcessorHook.lambda$processLogic$0(GameRequestMessageClientProcessorHook.java:38)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)

请问是哪里还没有设置正确吗?

iohao commented 1 year ago

一般是配置问题,看下相关网络配置。

zglbig commented 1 year ago

我在本地telnent 能ping通 10200 ,在服务网主机上也能连接10200 但是程序里边就没法连到网关

zglbig commented 1 year ago

防火墙也关了,安全组也有开放10200

zglbig commented 1 year ago

应该是网络配置的问题 我换了个没有安全组的云服务就可以了