You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dubbo provider side can't find service when deployed in docker. #1289
docker环境下对外服务的端口为DUBBO_PORT_TO_REGISTRY,但服务提供端在读取端口号时读取到的是本地端口号导致无法找到对应的服务。BUG信息如下:
Not found exported service: hbec.app.test.service.TestService:20881 in [hbec.app.test.service.TestService:31838]
问题代码如下:
DubboProtocol类
Invoker<?> getInvoker(Channel channel, Invocation inv) throws RemotingException {
boolean isCallBackServiceInvoke = false;
boolean isStubServiceInvoke = false;
int port = channel.getLocalAddress().getPort();//# 注:在docker环境下该端口取的是本地端口,非环境变量端口
String path = inv.getAttachments().get(Constants.PATH_KEY);
// if it's callback service on client side
isStubServiceInvoke = Boolean.TRUE.toString().equals(inv.getAttachments().get(Constants.STUB_EVENT_KEY));
if (isStubServiceInvoke) {
port = channel.getRemoteAddress().getPort();
}
DUBBO_IP_TO_REGISTRY and DUBBO_PORT_TO_REGISTRY don't affect the ip and port your provider bind to. If you only specify ip and port for registry and use different ip and port for binding, your network should have a mechanism to map registry ip/port with bind ip/port automatically. Like Port Mapping docker provides.
感谢你的回复,我们已经在docker中做了端口映射,并且我们通过命令
telnet 30.5.97.6 31838
ls
invoke hbec.app.test.service.TestService.test()
是可以正常调通并且我们在zookeeper中也是可以发现31838注册的provider服务,但我们通过consumer去调用provider端时,provider端会报如下错误:
Not found exported service: hbec.app.test.service.TestService:20881 in [hbec.app.test.service.TestService:31838]
Activity
[-]dubbo在docker环境下找不到服务问题[/-][+]dubbo provider side can't find service when deployed in docker.[/+]chickenlj commentedon Jan 29, 2018
DUBBO_IP_TO_REGISTRYandDUBBO_PORT_TO_REGISTRYdon't affect the ip and port your provider bind to. If you only specify ip and port for registry and use different ip and port for binding, your network should have a mechanism to map registry ip/port with bind ip/port automatically. LikePort Mappingdocker provides.skiof007 commentedon Jan 30, 2018
感谢你的回复,我们已经在docker中做了端口映射,并且我们通过命令
telnet 30.5.97.6 31838
ls
invoke hbec.app.test.service.TestService.test()
是可以正常调通并且我们在zookeeper中也是可以发现31838注册的provider服务,但我们通过consumer去调用provider端时,provider端会报如下错误:
Not found exported service: hbec.app.test.service.TestService:20881 in [hbec.app.test.service.TestService:31838]
我们通过修改DubboProtocol类源码:
Invoker<?> getInvoker(Channel channel, Invocation inv) throws RemotingException {
boolean isCallBackServiceInvoke = false;
boolean isStubServiceInvoke = false;
int port = channel.getLocalAddress().getPort();
经重新编译打包源码后测试调用成功。
docker端口映射代码如下:
"ports": [
{
"name": "dubbo",
"protocol": "TCP",
"port": 20881,
"targetPort": 20881,
"nodePort": 31838
}
]
Fixes #1289, use bind_port as mapping key
Merge alibaba/dubbo/master to myself repo (#1)
Merge alibaba/dubbo/master to myself repo. (#2)
Merge alibaba/dubbo/master to myself repo (#4)
Fixes apache#1289, use bind_port as mapping key