Connection timeout when building XMemcachedClient

97 views
Skip to first unread message

Derek

unread,
Nov 3, 2011, 3:51:58 AM11/3/11
to xmemcached
Hi, i am currently evaluating XMemcachedClient library, and I have a
question regarding to connection problem.

When I use MemcachedClientBuilder to create a MemcachdClient with code
like this

MemcachedClientBuilder builder = new
XMemcachedClientBuilder(AddrUtil.getAddressMap(strServer));
return builder.build();

I've found that the build() api will block if the specified server is
down.

I traced down the code, and see the default connect timeout is set to
60 seconds. There is apparently an api to change connect timeout
(setConnectTimeout), but I cannot use it until I get a MemcachedClient
object !!

Is there any way to get around it ? Otherwise my application will hang
on start up if the any of the referenced memcached server is down for
any reason.

Please help.

Thanks.

dennis

unread,
Nov 3, 2011, 4:17:04 AM11/3/11
to xmemcached
Yes,it's a problem in this situation.I am sorry now there is not a
method to set connectionTimeout.

A trick may be used now is to set
MemcachedClient.DEFAULT_CONNECT_TIMEOUT to a small value by reflection
at startup or you must be sure that memcached was startup before your
application.

I will add a new method to set connectTimeout to
MemcachedClientBuilder in the next release.

Derek Tu

unread,
Nov 3, 2011, 4:37:18 AM11/3/11
to xmemc...@googlegroups.com
Thanks for the quick response.

Would it be better, if the actual connection pool is defer started
until client actually call get or set ?
Since client application is expecting network error, so it is a much
better time for client to handle such situation ?

Also, if I set the pool size to be larger than 1, then current code
will try many times to connect to the remote server in sequence. This
will pose a much longer delay for client application if the remote
memcache server is down.

Looking for your update.

Thanks.

2011/11/3 dennis <killm...@gmail.com>:

> --
> You received this message because you are subscribed to the Google Groups "xmemcached" group.
> To post to this group, send email to xmemc...@googlegroups.com.
> To unsubscribe from this group, send email to xmemcached+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/xmemcached?hl=en.
>
>

Reply all
Reply to author
Forward
0 new messages