### Environment

* Dubbo version: 2.6.2
* Operating System version: CentOS7
* Java version: 1.8

### Steps to reproduce this issue

1. <dubbo:protocol name="rmi" port="20879" host="192.168.51.113" />  Select rmi 
protocol
2. The service provider is on the 192.168.51.113 machine
   Service consumers on other machines sun as 192.168.52.119
3. Service consumer reports exception, cannot find service exception is  
"java.rmi.ConnectException: Connection refused to host: localhost; nested 
exception is:"
   But I did not configure localhost at all.
   
Pls. provide [GitHub address] to reproduce this issue.

### Expected Result

The service consumer can get the address of the service provider correctly

### Actual Result

Service consumer reports exception, cannot find service exception is  
"java.rmi.ConnectException: Connection refused to host: localhost; nested 
exception is:"
But I did not configure localhost at all.

If there is an exception, please attach the exception trace:

```
 Caused by: com.alibaba.dubbo.rpc.RpcException: Failed to invoke the method 
getEquipInitListByCollectPointKey in the service 
com.agioe.atm.domain.monitoring.alarm.service.GlobalDevCacheService. Tried 1 
times of the providers [192.168.51.113:20879] (1/1) from the registry 
192.168.51.113:2181 on the consumer 192.168.52.119 using the dubbo version 
2.6.2. Last error is: Failed to invoke remote service: interface 
com.agioe.atm.domain.monitoring.alarm.service.GlobalDevCacheService, method: 
getEquipInitListByCollectPointKey, cause: Could not connect to remote service 
[rmi://192.168.51.113:20879/com.agioe.atm.domain.monitoring.alarm.service.GlobalDevCacheService];
 nested exception is java.rmi.ConnectException: Connection refused to host: 
localhost; nested exception is: 
        java.net.ConnectException: Connection refused: connect
        at 
com.alibaba.dubbo.rpc.cluster.support.FailoverClusterInvoker.doInvoke(FailoverClusterInvoker.java:102)
        at 
com.alibaba.dubbo.rpc.cluster.support.AbstractClusterInvoker.invoke(AbstractClusterInvoker.java:238)
        at 
com.alibaba.dubbo.rpc.cluster.support.wrapper.MockClusterInvoker.invoke(MockClusterInvoker.java:75)
        at 
com.alibaba.dubbo.rpc.proxy.InvokerInvocationHandler.invoke(InvokerInvocationHandler.java:52)
        at 
com.alibaba.dubbo.common.bytecode.proxy6.getEquipInitListByCollectPointKey(proxy6.java)
        at 
com.agioe.atm.alarmlinkage.engine.support.AlarmLinkageJmsListener.alarm(AlarmLinkageJmsListener.java:68)
        at 
com.agioe.atm.alarmlinkage.engine.support.AlarmLinkageJmsListener.lambda$recvRealtimeData$1(AlarmLinkageJmsListener.java:58)
        at 
java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
        at 
java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
        at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
        at java.util.stream.ForEachOps$ForEachTask.compute(ForEachOps.java:291)
        at java.util.concurrent.CountedCompleter.exec(CountedCompleter.java:731)
        at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
        at java.util.concurrent.ForkJoinTask.doInvoke(ForkJoinTask.java:401)
        at java.util.concurrent.ForkJoinTask.invoke(ForkJoinTask.java:734)
        at 
java.util.stream.ForEachOps$ForEachOp.evaluateParallel(ForEachOps.java:160)
        at 
java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateParallel(ForEachOps.java:174)
        at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:233)
        at 
java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
        at 
java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:583)
        at 
com.agioe.atm.alarmlinkage.engine.support.AlarmLinkageJmsListener.recvRealtimeData(AlarmLinkageJmsListener.java:58)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at 
org.springframework.messaging.handler.invocation.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:180)
        at 
org.springframework.messaging.handler.invocation.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:112)
        at 
org.springframework.jms.listener.adapter.MessagingMessageListenerAdapter.invokeHandler(MessagingMessageListenerAdapter.java:104)
        ... 10 common frames omitted
Caused by: org.springframework.remoting.RemoteConnectFailureException: Could 
not connect to remote service 
[rmi://192.168.51.113:20879/com.agioe.atm.domain.monitoring.alarm.service.GlobalDevCacheService];
 nested exception is java.rmi.ConnectException: Connection refused to host: 
localhost; nested exception is: 
```

### A piece of my mind

This seems to be a problem with the rmi protocol itself
   My solution is:
   System.setProperty("java.rmi.server.hostname", "192.168.51.113");

Now that dubbo has used zookeeper as a registry,can't you optimize this rmi 
protocol Naming.lookup ?

[ Full content available at: 
https://github.com/apache/incubator-dubbo/issues/2765 ]
This message was relayed via gitbox.apache.org for 
[email protected]

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to