dubbo telnet会创建netty udp clientclient么

dubbo报错求大神解答-中国学网-中国IT综合门户网站-提供健康,养生,留学,移民,创业,汽车等信息
dubbo报错求大神解答
来源:互联网 更新时间: 0:42:21 责任编辑:鲁晓倩字体:
很多朋友碰到怎样的问题:dubbo报错求大神解答,本网通过互联网收集了以下的答案,以方便用户参考解决问题,具体问题如下:&[DUBBO] Failed to start NettyClient caedmon-PC/192.168.0.234 connect to the server /60.191.124.236:20883 (check == false, ignore and retry later!), cause: client(url: dubbo://60.191.124.236:20883/ 用户提供的答案1:表示你的电脑连接不到192.168.0.234,check=false 表示记录失败注册和订阅请求,后台定时重试。用户提供的答案2:192.168.0.234就是我的ip用户提供的答案3:问题详细点。用户提供的答案4:
项目启动dubbo注册服务
就报这个错误
ERROR 10:16:41,178 AbstractClient:&init& - &[DUBBO] Failed to start NettyClient caedmon-PC/192.168.0.234 connect to the server /60.191.124.236:21890 (check == false, ignore and retry later!), cause: client(url: dubbo://60.191.124.236:21890/com.sendinfo.ebiz3.account.server.UserServer?anyhost=true&application=wuzhen-b2c-provider&check=false&codec=dubbo&default.check=false&default.retries=0&default.timeout=20000&dubbo=2.5.3&heartbeat=60000&interface=com.sendinfo.ebiz3.account.server.UserServer&methods=queryConsumerPointVo,updateAccount,queryConsumer,updateLogin,loginOut,getLogin,regConsumer,getAccount,queryLogin,updateConsumer&pid=6212&side=consumer&timeout=5000&timestamp=3) failed to connect to server /60.191.124.236:21890 client-side timeout 3000ms (elapsed: 3003ms) from netty client 192.168.0.234 using dubbo version 2.5.3, dubbo version: 2.5.3, current host: 192.168.0.234
com.alibaba.dubbo.remoting.RemotingException: client(url: dubbo://60.191.124.236:21890/com.sendinfo.ebiz3.account.server.UserServer?anyhost=true&application=wuzhen-b2c-provider&check=false&codec=dubbo&default.check=false&default.retries=0&default.timeout=20000&dubbo=2.5.3&heartbeat=60000&interface=com.sendinfo.ebiz3.account.server.UserServer&methods=queryConsumerPointVo,updateAccount,queryConsumer,updateLogin,loginOut,getLogin,regConsumer,getAccount,queryLogin,updateConsumer&pid=6212&side=consumer&timeout=5000&timestamp=3) failed to connect to server /60.191.124.236:21890 client-side timeout 3000ms (elapsed: 3003ms) from netty client 192.168.0.234 using dubbo version 2.5.3
相关文章:
上一篇文章:下一篇文章:
最新添加资讯
24小时热门资讯
Copyright © 2004- All Rights Reserved. 中国学网 版权所有
京ICP备号-1 京公网安备02号/ qf-dubbox
项目语言:JAVA
权限:read-only(如需更高权限请先加入项目)
qf-dubbox/
Index: netty/Hello.java
===================================================================
--- netty/Hello.java (revision 0)
+++ netty/Hello.java (revision 2)
@@ -0,0 +1,46 @@
+ * Copyright
Alibaba Group.
+ * Licensed under the Apache License, Version 2.0 (the &License&);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an &AS IS& BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+package com.alibaba.dubbo.remoting.transport.
+import java.io.S
+ * Result
+ * @author william.liangf
+public class Hello implements Serializable {
private static final long serialVersionUID = 3747774L;
public Hello() {
public Hello(String name) {
this.name =
public String getName() {
public void setName(String name) {
this.name =
\ No newline at end of file
Index: netty/WorldHandler.java
===================================================================
--- netty/WorldHandler.java (revision 0)
+++ netty/WorldHandler.java (revision 2)
@@ -0,0 +1,37 @@
+ * Copyright
Alibaba Group.
+ * Licensed under the Apache License, Version 2.0 (the &License&);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an &AS IS& BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+package com.alibaba.dubbo.remoting.transport.
+import com.alibaba.dubbo.remoting.RemotingE
+import com.alibaba.dubbo.remoting.exchange.ExchangeC
+import com.alibaba.dubbo.remoting.exchange.support.R
+ * DataHandler
+ * @author william.liangf
+public class WorldHandler implements Replier&World& {
public Class&World& interest() {
return World.
public Object reply(ExchangeChannel channel, World msg) throws RemotingException {
return new Hello(&hello,& + msg.getName());
\ No newline at end of file
Index: netty/World.java
===================================================================
--- netty/World.java (revision 0)
+++ netty/World.java (revision 2)
@@ -0,0 +1,46 @@
+ * Copyright
Alibaba Group.
+ * Licensed under the Apache License, Version 2.0 (the &License&);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an &AS IS& BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+package com.alibaba.dubbo.remoting.transport.
+import java.io.S
+ * @author william.liangf
+public class World implements Serializable {
private static final long serialVersionUID = 3747774L;
public World() {
public World(String name) {
this.name =
public String getName() {
public void setName(String name) {
this.name =
\ No newline at end of file
Index: netty/ClientToServerTest.java
===================================================================
--- netty/ClientToServerTest.java (revision 0)
+++ netty/ClientToServerTest.java (revision 2)
@@ -0,0 +1,93 @@
+ * Copyright
Alibaba Group.
+ * Licensed under the Apache License, Version 2.0 (the &License&);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an &AS IS& BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+package com.alibaba.dubbo.remoting.transport.
+import junit.framework.A
+import junit.framework.TestC
+import org.junit.T
+import com.alibaba.dubbo.remoting.RemotingE
+import com.alibaba.dubbo.remoting.exchange.ExchangeC
+import com.alibaba.dubbo.remoting.exchange.ExchangeS
+import com.alibaba.dubbo.remoting.exchange.ResponseF
+import com.alibaba.dubbo.remoting.exchange.support.R
+ * ClientToServer
+ * @author william.liangf
+public abstract class ClientToServerTest extends TestCase {
protected static final String LOCALHOST = &127.0.0.1&;
protected ExchangeS
protected ExchangeC
protected WorldHandler handler = new WorldHandler();
protected abstract ExchangeServer newServer(int port, Replier&?& receiver) throws RemotingE
protected abstract ExchangeChannel newClient(int port) throws RemotingE
protected void setUp() throws Exception {
super.setUp();
int port = (int) (1000 * Math.random() + 10000);
server = newServer(port, handler);
client = newClient(port);
protected void tearDown() throws Exception {
super.tearDown();
if (server != null)
server.close();
} finally {
if (client != null)
client.close();
public void testFuture() throws Exception {
ResponseFuture future = client.request(new World(&world&));
Hello result = (Hello)future.get();
Assert.assertEquals(&hello,world&, result.getName());
public void testCallback() throws Exception {
final Object waitter = new Object();
client.invoke(new World(&world&), new InvokeCallback&Hello&() {
public void callback(Hello result) {
Assert.assertEquals(&hello,world&, result.getName());
synchronized (waitter) {
waitter.notifyAll();
public void onException(Throwable exception) {
synchronized (waitter) {
waitter.wait();
\ No newline at end of file
Index: netty/TelnetClientHandler.java
===================================================================
--- netty/TelnetClientHandler.java (revision 0)
+++ netty/TelnetClientHandler.java (revision 2)
@@ -0,0 +1,36 @@
+ * Copyright
Alibaba Group.
+ * Licensed under the Apache License, Version 2.0 (the &License&);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an &AS IS& BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+package com.alibaba.dubbo.remoting.transport.
+import com.alibaba.dubbo.remoting.RemotingE
+import com.alibaba.dubbo.remoting.exchange.ExchangeC
+import com.alibaba.dubbo.remoting.exchange.support.R
+ * User: heyman
+ * Date: 4/28/11
+ * Time: 11:15 AM
+public class TelnetClientHandler implements Replier&String& {
public Class&String& interest() {
return String.
public Object reply(ExchangeChannel channel, String msg) throws RemotingException {
\ No newline at end of file
Index: netty/ThreadNameTest.java
===================================================================
--- netty/ThreadNameTest.java (revision 0)
+++ netty/ThreadNameTest.java (revision 2)
@@ -0,0 +1,134 @@
+ * Copyright
Alibaba Group.
+ * Licensed under the Apache License, Version 2.0 (the &License&);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an &AS IS& BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+package com.alibaba.dubbo.remoting.transport.
+import org.junit.A
+import org.junit.A
+import org.junit.B
+import org.junit.T
+import com.mon.URL;
+import com.alibaba.dubbo.remoting.C
+import com.alibaba.dubbo.remoting.ChannelH
+import com.alibaba.dubbo.remoting.RemotingE
+ * @author &a href=&mailto:gang.lvg@&&kimi&/a&
+public class ThreadNameTest {
private NettyS
private NettyC
private URL serverURL;
private URL clientURL;
private ThreadNameVerifyHandler serverH
private ThreadNameVerifyHandler clientH
public void before() throws Exception {
int port = 55555;
serverURL = URL.valueOf(&netty://localhost&).setPort(port);
clientURL = URL.valueOf(&netty://localhost&).setPort(port);
serverHandler = new ThreadNameVerifyHandler(String.valueOf(port), false);
clientHandler = new ThreadNameVerifyHandler(String.valueOf(port), true);
server = new NettyServer(serverURL, serverHandler);
client = new NettyClient(clientURL, clientHandler);
public void after() throws Exception {
if (client != null) {
client.close();
if (server != null) {
server.close();
public void testThreadName() throws Exception {
client.send(&hello&);
Thread.sleep(1000L * 5L);
if (!serverHandler.isSuccess() || !clientHandler.isSuccess()) {
Assert.fail();
class ThreadNameVerifyHandler implements ChannelHandler {
public boolean isSuccess() {
ThreadNameVerifyHandler(String msg, boolean client) {
this.client =
private void checkThreadName() {
if (!success) {
success = Thread.currentThread().getName().contains(message);
private void output(String method) {
System.out.println(Thread.currentThread().getName()
+ & & + (client ? &client & + method : &server & + method));
public void connected(Channel channel) throws RemotingException {
output(&connected&);
checkThreadName();
public void disconnected(Channel channel) throws RemotingException {
output(&disconnected&);
checkThreadName();
public void sent(Channel channel, Object message) throws RemotingException {
output(&sent&);
checkThreadName();
public void received(Channel channel, Object message) throws RemotingException {
output(&received&);
checkThreadName();
public void caught(Channel channel, Throwable exception) throws RemotingException {
output(&caught&);
checkThreadName();
\ No newline at end of file
Index: netty/NettyStringTest.java
===================================================================
--- netty/NettyStringTest.java (revision 0)
+++ netty/NettyStringTest.java (revision 2)
@@ -0,0 +1,64 @@
+ * Copyright
Alibaba Group.
+ * Licensed under the Apache License, Version 2.0 (the &License&);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an &AS IS& BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+package com.alibaba.dubbo.remoting.transport.
+import org.junit.AfterC
+import org.junit.BeforeC
+import org.junit.T
+import com.mon.URL;
+import com.alibaba.dubbo.remoting.exchange.ExchangeC
+import com.alibaba.dubbo.remoting.exchange.ExchangeS
+import com.alibaba.dubbo.remoting.exchange.E
+ * User: heyman
+ * Date: 4/26/11
+ * Time: 4:13 PM
+public class NettyStringTest {
static ExchangeS
static ExchangeC
@BeforeClass
public static void setUp() throws Exception {
//int port = (int) (1000 * Math.random() + 10000);
int port = 10001;
System.out.println(port);
server = Exchangers.bind(URL.valueOf(&telnet://0.0.0.0:& + port + &?server=netty&), new TelnetServerHandler());
client = Exchangers.connect(URL.valueOf(&telnet://127.0.0.1:& + port + &?client=netty&), new TelnetClientHandler());
public void testHandler() throws Exception {
//Thread.sleep(20000);
/*client.request(&world\r\n&);
Future future = client.request(&world&, 10000);
String result = (String)future.get();
Assert.assertEquals(&Did you say 'world'?\r\n&,result);*/
@AfterClass
public static void tearDown() throws Exception {
if (server != null)
server.close();
} finally {
if (client != null)
client.close();
\ No newline at end of file
Index: netty/NettyClientToServerTest.java
===================================================================
--- netty/NettyClientToServerTest.java (revision 0)
+++ netty/NettyClientToServerTest.java (revision 2)
@@ -0,0 +1,40 @@
+ * Copyright
Alibaba Group.
+ * Licensed under the Apache License, Version 2.0 (the &License&);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an &AS IS& BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+package com.alibaba.dubbo.remoting.transport.
+import com.mon.URL;
+import com.alibaba.dubbo.remoting.RemotingE
+import com.alibaba.dubbo.remoting.exchange.ExchangeC
+import com.alibaba.dubbo.remoting.exchange.ExchangeS
+import com.alibaba.dubbo.remoting.exchange.E
+import com.alibaba.dubbo.remoting.exchange.support.R
+ * NettyClientToServerTest
+ * @author william.liangf
+public class NettyClientToServerTest extends ClientToServerTest {
protected ExchangeServer newServer(int port, Replier&?& receiver) throws RemotingException {
return Exchangers.bind(URL.valueOf(&exchange://localhost:& + port + &?server=netty&), receiver);
protected ExchangeChannel newClient(int port) throws RemotingException {
return Exchangers.connect(URL.valueOf(&exchange://localhost:& + port + &?client=netty&));
\ No newline at end of file
Index: netty/ClientReconnectTest.java
===================================================================
--- netty/ClientReconnectTest.java (revision 0)
+++ netty/ClientReconnectTest.java (revision 2)
@@ -0,0 +1,179 @@
+ * Copyright
Alibaba Group.
+ * Licensed under the Apache License, Version 2.0 (the &License&);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an &AS IS& BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+package com.alibaba.dubbo.remoting.transport.
+import org.apache.log4j.L
+import org.junit.A
+import org.junit.T
+import com.mon.C
+import com.mon.utils.DubboA
+import com.mon.utils.LogU
+import com.mon.utils.NetU
+import com.alibaba.dubbo.remoting.C
+import com.alibaba.dubbo.remoting.C
+import com.alibaba.dubbo.remoting.RemotingE
+import com.alibaba.dubbo.remoting.S
+import com.alibaba.dubbo.remoting.exchange.E
+import com.alibaba.dubbo.remoting.exchange.support.ExchangeHandlerA
+ * 客户端重连测试
+ * @author chao.liuc
+public class ClientReconnectTest {
public void testReconnect() throws RemotingException, InterruptedException{
int port = NetUtils.getAvailablePort();
Client client = startClient(port, 200);
Assert.assertEquals(false, client.isConnected());
Server server = startServer(port);
for (int i = 0; i & 100 && ! client.isConnected(); i++) {
Thread.sleep(10);
Assert.assertEquals(true, client.isConnected());
client.close(2000);
server.close(2000);
int port = NetUtils.getAvailablePort();
Client client = startClient(port, 20000);
Assert.assertEquals(false, client.isConnected());
Server server = startServer(port);
for(int i=0;i&5;i++){
Thread.sleep(200);
Assert.assertEquals(false, client.isConnected());
client.close(2000);
server.close(2000);
* 重连日志的校验,时间不够shutdown time时,不能有error日志,但必须有一条warn日志
public void testReconnectWarnLog() throws RemotingException, InterruptedException{
int port = NetUtils.getAvailablePort();
DubboAppender.doStart();
String url = &exchange://127.0.0.2:&+port + &/client.reconnect.test?check=false&&
+Constants.RECONNECT_KEY+&=&+1 ; //1ms reconnect,保证有足够频率的重连
Exchangers.connect(url);
}catch (Exception e) {
//do nothing
Thread.sleep(1500);//重连线程的运行
//时间不够长,不会产生error日志
Assert.assertEquals(&no error message &, 0 , LogUtil.findMessage(Level.ERROR, &client reconnect to &));
//第一次重连失败就会有warn日志
Assert.assertEquals(&must have one warn message &, 1 , LogUtil.findMessage(Level.WARN, &client reconnect to &));
DubboAppender.doStop();
* 重连日志的校验,不能一直抛出error日志.
public void testReconnectErrorLog() throws RemotingException, InterruptedException{
int port = NetUtils.getAvailablePort();
DubboAppender.doStart();
String url = &exchange://127.0.0.3:&+port + &/client.reconnect.test?check=false&&
+Constants.RECONNECT_KEY+&=&+1 + //1ms reconnect,保证有足够频率的重连
&&&+Constants.SHUTDOWN_TIMEOUT_KEY+ &=1&;//shutdown时间足够短,确保error日志输出
Exchangers.connect(url);
}catch (Exception e) {
//do nothing
Thread.sleep(1500);//重连线程的运行
Assert.assertEquals(&only one error message &, 1 , LogUtil.findMessage(Level.ERROR, &client reconnect to &));
DubboAppender.doStop();
* 测试client重连方法不会导致重连线程失效.
public void testClientReconnectMethod() throws RemotingException, InterruptedException{
int port = NetUtils.getAvailablePort();
String url = &exchange://127.0.0.3:&+port + &/client.reconnect.test?check=false&&
+Constants.RECONNECT_KEY+&=&+10 //1ms reconnect,保证有足够频率的重连
+&&reconnect.waring.period=1&;
DubboAppender.doStart();
Client client = Exchangers.connect(url);
client.reconnect();
} catch (Exception e) {
//do nothing
Thread.sleep(1500);//重连线程的运行
Assert.assertTrue(&have more then one warn msgs . bug was :& + LogUtil.findMessage(Level.WARN, &client reconnect to &),LogUtil.findMessage(Level.WARN, &client reconnect to &) &1);
DubboAppender.doStop();
public static void main(String[] args) {
System.out.println(3%1);
* 重连日志的校验
public void testReconnectWaringLog() throws RemotingException, InterruptedException{
int port = NetUtils.getAvailablePort();
DubboAppender.doStart();
String url = &exchange://127.0.0.4:&+port + &/client.reconnect.test?check=false&&
+Constants.RECONNECT_KEY+&=&+1 //1ms reconnect,保证有足够频率的重连
+&&&+Constants.SHUTDOWN_TIMEOUT_KEY+ &=1&//shutdown时间足够短,确保error日志输出
+&&reconnect.waring.period=100&;//每隔多少warning记录一次
Exchangers.connect(url);
}catch (Exception e) {
//do nothing
int count =
for (int i=0;i&100;i++){
LogUtil.findMessage(Level.WARN, &client reconnect to &) ;
if (count &=1){
Thread.sleep(50);//重连线程的运行
Assert.assertTrue(&warning message count must &= 1, real :&+count, count&= 1);
DubboAppender.doStop();
public Client startClient(int port , int reconnectPeriod) throws RemotingException{
final String url = &exchange://127.0.0.1:&+port + &/client.reconnect.test?check=false&&+Constants.RECONNECT_KEY+&=&+reconnectP
return Exchangers.connect(url);
public Server startServer(int port) throws RemotingException{
final String url = &exchange://127.0.0.1:&+port +&/client.reconnect.test&;
return Exchangers.bind(url, new HandlerAdapter());
static class HandlerAdapter extends ExchangeHandlerAdapter{
public void connected(Channel channel) throws RemotingException {
public void disconnected(Channel channel) throws RemotingException {
public void caught(Channel channel, Throwable exception) throws RemotingException {
\ No newline at end of file
Index: netty/TelnetServerHandler.java
===================================================================
--- netty/TelnetServerHandler.java (revision 0)
+++ netty/TelnetServerHandler.java (revision 2)
@@ -0,0 +1,46 @@
+ * Copyright
Alibaba Group.
+ * Licensed under the Apache License, Version 2.0 (the &License&);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an &AS IS& BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+package com.alibaba.dubbo.remoting.transport.
+import com.alibaba.dubbo.remoting.RemotingE
+import com.alibaba.dubbo.remoting.exchange.ExchangeC
+import com.alibaba.dubbo.remoting.exchange.support.R
+ * User: heyman
+ * Date: 4/26/11
+ * Time: 4:29 PM
+public class TelnetServerHandler implements Replier&String& {
public Class&String& interest() {
return String.
public Object reply(ExchangeChannel channel, String msg) throws RemotingException {
// Generate and write a response.
if (msg.length() == 0) {
response = &Please type something.\r\n&;
response = &Did you say '& + msg + &'?\r\n&;
//System.out.println(response);
\ No newline at end of file
Index: netty/ClientsTest.java
===================================================================
--- netty/ClientsTest.java (revision 0)
+++ netty/ClientsTest.java (revision 2)
@@ -0,0 +1,61 @@
+ * Copyright
Alibaba Group.
+ * Licensed under the Apache License, Version 2.0 (the &License&);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an &AS IS& BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+package com.alibaba.dubbo.remoting.transport.
+import static org.junit.Assert.assertE
+import static org.junit.Assert.assertN
+import static org.junit.Assert.assertT
+import static org.junit.Assert.
+import static org.junit.matchers.JUnitMatchers.containsS
+import org.junit.T
+import com.mon.extension.ExtensionL
+import com.alibaba.dubbo.remoting.T
+ * @author ding.lid
+public class ClientsTest {
public void testGetTransportEmpty() {
ExtensionLoader.getExtensionLoader(Transporter.class).getExtension(&&);
} catch (IllegalArgumentException expected) {
assertThat(expected.getMessage(), containsString(&Extension name == null&));
@Test(expected = IllegalArgumentException.class)
public void testGetTransportNull() {
String name =
ExtensionLoader.getExtensionLoader(Transporter.class).getExtension(name);
public void testGetTransport3() {
String name = &netty&;
assertEquals(NettyTransporter.class, ExtensionLoader.getExtensionLoader(Transporter.class).getExtension(name).getClass());
@Test(expected = IllegalStateException.class)
public void testGetTransportWrong() {
String name = &nety&;
assertNull(ExtensionLoader.getExtensionLoader(Transporter.class).getExtension(name).getClass());
\ No newline at end of file
Index: netty/NettyClientTest.java
===================================================================
--- netty/NettyClientTest.java (revision 0)
+++ netty/NettyClientTest.java (revision 2)
@@ -0,0 +1,79 @@
+ * Copyright
Alibaba Group.
+ * Licensed under the Apache License, Version 2.0 (the &License&);
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an &AS IS& BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+package com.alibaba.dubbo.remoting.transport.
+import java.util.ArrayL
+import java.util.L
+import org.junit.AfterC
+import org.junit.BeforeC
+import org.junit.T
+import com.mon.URL;
+import com.alibaba.dubbo.remoting.RemotingE
+import com.alibaba.dubbo.remoting.S
+import com.alibaba.dubbo.remoting.exchange.ExchangeC
+import com.alibaba.dubbo.remoting.exchange.E
+ * User: heyman
+ * Date: 5/3/11
+ * Time: 5:47 PM
+public class NettyClientTest {
@BeforeClass
public static void setUp() throws Exception {
server = Exchangers.bind(URL.valueOf(&exchange://localhost:10001?server=netty&), new TelnetServerHandler());
public void testClientClose() throws Exception {
List&ExchangeChannel& clients = new ArrayList&ExchangeChannel&(100);
for (int i = 0; i & 100; i++) {
ExchangeChannel client = Exchangers.connect(URL.valueOf(&exchange://localhost:10001?client=netty&));
Thread.sleep(5);
clients.add(client);
for (ExchangeChannel client : clients){
client.close();
Thread.sleep(1000);
public void testServerClose() throws Exception {
for (int i = 0; i & 100; i++) {
Server aServer = Exchangers.bind(URL.valueOf(&exchange://localhost:& + (5000 + i) + &?client=netty&), new TelnetServerHandler());
aServer.close();
@AfterClass
public static void tearDown() throws Exception {
if (server != null)
server.close();
} finally {}
public static void main(String[] args) throws RemotingException, InterruptedException {
ExchangeChannel client = Exchangers.connect(URL.valueOf(&exchange://10.20.153.10:20880?client=netty&heartbeat=1000&));
Thread.sleep(60*1000*50);
\ No newline at end of file
Index: dispatcher/FakeChannelHandlers.java
===================================================================
--- dispatcher/FakeChannelHandlers.java (revision 0)
+++ dispatcher/FakeChannelHandlers.java (revision 2)
@@ -0,0 +1,46 @@
+ * Copyright
Alibaba Group.
Licensed under the Apache License, Version 2.0 (the &License&);
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an &AS IS& BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
+package com.alibaba.dubbo.remoting.transport.
+import com.mon.URL;
+import com.mon.extension.ExtensionL
+import com.alibaba.dubbo.remoting.ChannelH
+import com.alibaba.dubbo.remoting.D
+ * @author &a href=&mailto:gang.lvg@&&kimi&/a&
+public class FakeChannelHandlers extends ChannelHandlers {
public FakeChannelHandlers() {
protected ChannelHandler wrapInternal(ChannelHandler handler, URL url) {
return ExtensionLoader.getExtensionLoader(Dispatcher.class)
.getAdaptiveExtension().dispatch(handler, url);
public static void setTestingChannelHandlers() {
ChannelHandlers.setTestingChannelHandlers(new FakeChannelHandlers());
public static void resetChannelHandlers() {
ChannelHandlers.setTestingChannelHandlers(new ChannelHandlers());
(C)&&2013&&Alibaba&&Inc.&&All&&rights&&resvered.
Powered by

我要回帖

更多关于 netty client 连接池 的文章

 

随机推荐