New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

两种不同方式,但是用client连接到服务失败,这是为什么? #181

Closed
cheniqit opened this Issue Aug 24, 2016 · 10 comments

Comments

Projects
None yet
2 participants
@cheniqit

cheniqit commented Aug 24, 2016

第一步:
首先我用简单的main方法加载xml来启动motan服务,启动成功。
然后用client去连接用main方法启动的服务,是连接成功的。

第二步:
我想集成到项目中,并用tomcat启动,发现启动成功。
但是我用第一步的clent去连接服务的时候,发现连接失败。报错如下:

info - ClusterSupport config change notify: registry=local://127.0.0.1:0/com.weibo.api.motan.registry.RegistryService service=motan://192.168.31.244:0/default_rpc/com.mk.hotel.hotelinfo.HotelService/1.0/referer urls=[motan://localhost:10068/default_rpc/com.mk.hotel.hotelinfo.HotelService/1.0/service]
11:51:16.766 [RMI TCP Connection(2)-127.0.0.1] INFO info - refresh weight. weight=
11:51:16.766 [RMI TCP Connection(2)-127.0.0.1] INFO info - ignore weightString:
11:51:16.800 [RMI TCP Connection(2)-127.0.0.1] INFO info - NettyEndpointFactory create client: url=motan://localhost:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc
11:51:16.910 [RMI TCP Connection(2)-127.0.0.1] INFO info - init compress codec
11:51:16.914 [RMI TCP Connection(2)-127.0.0.1] INFO info - init nettyclient. url:localhost-com.mk.hotel.hotelinfo.HotelService, use codec:DefaultRpcCodec
11:51:17.018 [New I/O client boss #1] ERROR error - NettyChannelHandler exceptionCaught: remote=null local=null event=java.net.ConnectException: Connection refused
java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.7.0_79]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) ~[na:1.7.0_79]
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.connect(NioClientSocketPipelineSink.java:384) ~[netty-3.2.5.Final.jar:na]
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processSelectedKeys(NioClientSocketPipelineSink.java:354) ~[netty-3.2.5.Final.jar:na]
at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:276) ~[netty-3.2.5.Final.jar:na]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_79]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_79]
at java.lang.Thread.run(Thread.java:745) [na:1.7.0_79]
11:51:17.032 [RMI TCP Connection(2)-127.0.0.1] ERROR error - NettyClient init pool create connect Error: url=motan://localhost:10068/com.mk.hotel.hotelinfo.HotelService
com.weibo.api.motan.exception.MotanServiceException: error_message: NettyChannel failed to connect to server, url: motan://localhost:10068/com.mk.hotel.hotelinfo.HotelService, result: true, success: false, connected: false, status: 503, error_code: 10001,r=
at com.weibo.api.motan.transport.netty.NettyChannel.open(NettyChannel.java:150) ~[motan-transport-netty-0.1.1.jar:na]
at com.weibo.api.motan.transport.netty.NettyChannelFactory.makeObject(NettyChannelFactory.java:53) ~[motan-transport-netty-0.1.1.jar:na]
at org.apache.commons.pool.impl.GenericObjectPool.addObject(GenericObjectPool.java:1617) ~[commons-pool-1.5.4.jar:1.5.4]
at com.weibo.api.motan.transport.AbstractPoolClient.initPool(AbstractPoolClient.java:64) ~[motan-core-0.1.1.jar:na]
at com.weibo.api.motan.transport.netty.NettyClient.open(NettyClient.java:217) [motan-transport-netty-0.1.1.jar:na]

顺便,我贴上两次启动服务的日志都是一样的:
main方法启动服务:
11:37:51.118 [main] INFO info - RequestRouter addProvider: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc all_public_method_count=13
11:37:51.138 [main] INFO info - NettyEndpointFactory create no_share_channel server: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc
11:37:51.200 [main] INFO info - NettyServer ServerChannel start Open: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc
11:37:51.285 [main] INFO info - NettyServer ServerChannel finish Open: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc
11:37:51.286 [main] INFO info - DefaultRpcExporter node init Success: [DefaultRpcExporter] url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc
11:37:51.287 [main] INFO info - DefaultRpcProtocol export Success: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc
11:37:51.298 [main] INFO info - [LocalRegistryService] Url (motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc) will register to Registry [local://127.0.0.1:0/default_rpc/com.weibo.api.motan.registry.RegistryService/1.0/service]
11:37:51.298 [main] INFO info - LocalRegistryService register: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc

用tomcate启动服务:
11:39:58.706 [RMI TCP Connection(2)-127.0.0.1] INFO info - RequestRouter addProvider: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc all_public_method_count=13
11:39:58.715 [RMI TCP Connection(2)-127.0.0.1] INFO info - NettyEndpointFactory create no_share_channel server: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc
11:39:58.745 [RMI TCP Connection(2)-127.0.0.1] INFO info - NettyServer ServerChannel start Open: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc
11:39:58.820 [RMI TCP Connection(2)-127.0.0.1] INFO info - NettyServer ServerChannel finish Open: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc
11:39:58.821 [RMI TCP Connection(2)-127.0.0.1] INFO info - DefaultRpcExporter node init Success: [DefaultRpcExporter] url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc
11:39:58.822 [RMI TCP Connection(2)-127.0.0.1] INFO info - DefaultRpcProtocol export Success: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc
11:39:58.830 [RMI TCP Connection(2)-127.0.0.1] INFO info - [LocalRegistryService] Url (motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc) will register to Registry [local://127.0.0.1:0/default_rpc/com.weibo.api.motan.registry.RegistryService/1.0/service]
11:39:58.830 [RMI TCP Connection(2)-127.0.0.1] INFO info - LocalRegistryService register: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService?group=default_rpc

@cheniqit cheniqit changed the title from 两中不同方式,但是用client连接到服务失败,这是为什么? to 两种不同方式,但是用client连接到服务失败,这是为什么? Aug 24, 2016

@cheniqit

This comment has been minimized.

Show comment
Hide comment
@cheniqit

cheniqit Aug 24, 2016

我也参考了项目组提供的错误码尝试去解决问题,但是我发现服务端是启动是成功的。

cheniqit commented Aug 24, 2016

我也参考了项目组提供的错误码尝试去解决问题,但是我发现服务端是启动是成功的。

@rayzhang0603

This comment has been minimized.

Show comment
Hide comment
@rayzhang0603

rayzhang0603 Aug 24, 2016

Collaborator

java.net.ConnectException: Connection refused 这个是原因。
motan://localhost:10068/default_rpc/com.mk.hotel.hotelinfo.HotelService/1.这个是获取到的server信息,请检查是不是hosts没有配置localhost

Collaborator

rayzhang0603 commented Aug 24, 2016

java.net.ConnectException: Connection refused 这个是原因。
motan://localhost:10068/default_rpc/com.mk.hotel.hotelinfo.HotelService/1.这个是获取到的server信息,请检查是不是hosts没有配置localhost

@cheniqit

This comment has been minimized.

Show comment
Hide comment
@cheniqit

cheniqit Aug 24, 2016

有配置的,通过main方法启动是成功的可以看到日志信息,tomcate启动服务看到的日志信息也是启动成功的。
@rayzhang0603
host配置如下:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
#::1             localhost

cheniqit commented Aug 24, 2016

有配置的,通过main方法启动是成功的可以看到日志信息,tomcate启动服务看到的日志信息也是启动成功的。
@rayzhang0603
host配置如下:

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1       localhost
255.255.255.255 broadcasthost
#::1             localhost
@cheniqit

This comment has been minimized.

Show comment
Hide comment
@cheniqit

cheniqit Aug 24, 2016

@rayzhang0603
我改client端的配置改成我的自己的ip之后也还是连接失败。

配置信息如下:
<motan:referer id="remoteHotelService" requestTimeout="3000" interface="com.mk.hotel.hotelinfo.HotelService" directUrl="192.168.59.3:10068" protocol="motan"/>

报错信息如下:

MI TCP Connection(2)-127.0.0.1] INFO info - init nettyclient. url:192.168.59.3-com.mk.hotel.hotelinfo.HotelService, use codec:DefaultRpcCodec 14:06:11.868 [New I/O client boss #1] ERROR error - NettyChannelHandler exceptionCaught: remote=null local=null event=java.net.ConnectException: Connection refused java.net.ConnectException: Connection refused at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.7.0_79] at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) ~[na:1.7.0_79] at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.connect(NioClientSocketPipelineSink.java:384) ~[netty-3.2.5.Final.jar:na] at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processSelectedKeys(NioClientSocketPipelineSink.java:354) ~[netty-3.2.5.Final.jar:na] at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:276) ~[netty-3.2.5.Final.jar:na] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_79] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_79] at java.lang.Thread.run(Thread.java:745) [na:1.7.0_79] 14:06:11.870 [RMI TCP Connection(2)-127.0.0.1] ERROR error - NettyClient init pool create connect Error: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService com.weibo.api.motan.exception.MotanServiceException: error_message: NettyChannel failed to connect to server, url: motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService, result: true, success: false, connected: false, status: 503, error_code: 10001,r= at com.weibo.api.motan.transport.netty.NettyChannel.open(NettyChannel.java:150) ~[motan-transport-netty-0.1.1.jar:na] at com.weibo.api.motan.transport.netty.NettyChannelFactory.makeObject(NettyChannelFactory.java:53) ~[motan-transport-netty-0.1.1.jar:na] at org.apache.commons.pool.impl.GenericObjectPool.addObject(GenericObjectPool.java:1617) ~[commons-pool-1.5.4.jar:1.5.4] at com.weibo.api.motan.transport.AbstractPoolClient.initPool(AbstractPoolClient.java:64) ~[motan-core-0.1.1.jar:na] at com.weibo.api.motan.transport.netty.NettyClient.open(NettyClient.java:217) [motan-transport-netty-0.1.1.jar:na] at com.weibo.api.motan.protocol.rpc.DefaultRpcProtocol$DefaultRpcReferer.doInit(DefaultRpcProtocol.java:196) [motan-core-0.1.1.jar:na] at com.weibo.api.motan.rpc.AbstractNode.init(AbstractNode.java:46) [motan-core-0.1.1.jar:na]

cheniqit commented Aug 24, 2016

@rayzhang0603
我改client端的配置改成我的自己的ip之后也还是连接失败。

配置信息如下:
<motan:referer id="remoteHotelService" requestTimeout="3000" interface="com.mk.hotel.hotelinfo.HotelService" directUrl="192.168.59.3:10068" protocol="motan"/>

报错信息如下:

MI TCP Connection(2)-127.0.0.1] INFO info - init nettyclient. url:192.168.59.3-com.mk.hotel.hotelinfo.HotelService, use codec:DefaultRpcCodec 14:06:11.868 [New I/O client boss #1] ERROR error - NettyChannelHandler exceptionCaught: remote=null local=null event=java.net.ConnectException: Connection refused java.net.ConnectException: Connection refused at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) ~[na:1.7.0_79] at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:739) ~[na:1.7.0_79] at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.connect(NioClientSocketPipelineSink.java:384) ~[netty-3.2.5.Final.jar:na] at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.processSelectedKeys(NioClientSocketPipelineSink.java:354) ~[netty-3.2.5.Final.jar:na] at org.jboss.netty.channel.socket.nio.NioClientSocketPipelineSink$Boss.run(NioClientSocketPipelineSink.java:276) ~[netty-3.2.5.Final.jar:na] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [na:1.7.0_79] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [na:1.7.0_79] at java.lang.Thread.run(Thread.java:745) [na:1.7.0_79] 14:06:11.870 [RMI TCP Connection(2)-127.0.0.1] ERROR error - NettyClient init pool create connect Error: url=motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService com.weibo.api.motan.exception.MotanServiceException: error_message: NettyChannel failed to connect to server, url: motan://192.168.59.3:10068/com.mk.hotel.hotelinfo.HotelService, result: true, success: false, connected: false, status: 503, error_code: 10001,r= at com.weibo.api.motan.transport.netty.NettyChannel.open(NettyChannel.java:150) ~[motan-transport-netty-0.1.1.jar:na] at com.weibo.api.motan.transport.netty.NettyChannelFactory.makeObject(NettyChannelFactory.java:53) ~[motan-transport-netty-0.1.1.jar:na] at org.apache.commons.pool.impl.GenericObjectPool.addObject(GenericObjectPool.java:1617) ~[commons-pool-1.5.4.jar:1.5.4] at com.weibo.api.motan.transport.AbstractPoolClient.initPool(AbstractPoolClient.java:64) ~[motan-core-0.1.1.jar:na] at com.weibo.api.motan.transport.netty.NettyClient.open(NettyClient.java:217) [motan-transport-netty-0.1.1.jar:na] at com.weibo.api.motan.protocol.rpc.DefaultRpcProtocol$DefaultRpcReferer.doInit(DefaultRpcProtocol.java:196) [motan-core-0.1.1.jar:na] at com.weibo.api.motan.rpc.AbstractNode.init(AbstractNode.java:46) [motan-core-0.1.1.jar:na]

@rayzhang0603

This comment has been minimized.

Show comment
Hide comment
@rayzhang0603

rayzhang0603 Aug 24, 2016

Collaborator

java.net.ConnectException: Connection refused 从这个方向找找看吧,看对应端口是否正确,telnet是否能连接上

Collaborator

rayzhang0603 commented Aug 24, 2016

java.net.ConnectException: Connection refused 从这个方向找找看吧,看对应端口是否正确,telnet是否能连接上

@cheniqit

This comment has been minimized.

Show comment
Hide comment
@cheniqit

cheniqit Aug 24, 2016

➜ 1.0-SNAPSHOT git:(master) ✗ telnet 192.168.59.3 10068 Trying 192.168.59.3... Connected to 192.168.59.3. Escape character is '^]'.

之前我也欢迎是这个问题。但是我telnet过了,是可以的。

cheniqit commented Aug 24, 2016

➜ 1.0-SNAPSHOT git:(master) ✗ telnet 192.168.59.3 10068 Trying 192.168.59.3... Connected to 192.168.59.3. Escape character is '^]'.

之前我也欢迎是这个问题。但是我telnet过了,是可以的。

@rayzhang0603

This comment has been minimized.

Show comment
Hide comment
@rayzhang0603

rayzhang0603 Aug 24, 2016

Collaborator

client和server是在不同的主机上吧?有设置iptables之类的吗?从这个报错上看建立socket就失败了

Collaborator

rayzhang0603 commented Aug 24, 2016

client和server是在不同的主机上吧?有设置iptables之类的吗?从这个报错上看建立socket就失败了

@cheniqit

This comment has been minimized.

Show comment
Hide comment
@cheniqit

cheniqit Aug 24, 2016

@rayzhang0603

发现一个奇怪的现象,刚开始启动服务端的时候,telnet是可以。一旦启动client之后就telnet就不通了,这个是为何? client是没有启动服务的

cheniqit commented Aug 24, 2016

@rayzhang0603

发现一个奇怪的现象,刚开始启动服务端的时候,telnet是可以。一旦启动client之后就telnet就不通了,这个是为何? client是没有启动服务的

@cheniqit cheniqit closed this Aug 24, 2016

@cheniqit

This comment has been minimized.

Show comment
Hide comment
@cheniqit

cheniqit Aug 24, 2016

在同一机器上面。

cheniqit commented Aug 24, 2016

在同一机器上面。

@rayzhang0603

This comment has been minimized.

Show comment
Hide comment
@rayzhang0603

rayzhang0603 Aug 24, 2016

Collaborator

估计跟server和client的spring配置加载方式有关,可能是什么操作导致server端停止服务了。建议debug看看client初始化时有没有影响到server吧

Collaborator

rayzhang0603 commented Aug 24, 2016

估计跟server和client的spring配置加载方式有关,可能是什么操作导致server端停止服务了。建议debug看看client初始化时有没有影响到server吧

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment