memcached icon indicating copy to clipboard operation
memcached copied to clipboard

Error: Server at 127.0.0.1:11211 not available

Open 4h0y opened this issue 9 years ago • 17 comments

LOG

Error: Server at 127.0.0.1:11211 not available
at Client.memcachedCommand [as command] (/home/hello.com/node_modules/memcached/lib/memcached.js:306:70)
at Client.get (/home/hello.com/node_modules/memcached/lib/memcached.js:830:10)

But Memcached active.

# service memcached status
● memcached.service - memcached daemon
   Loaded: loaded (/lib/systemd/system/memcached.service; disabled)
   Active: active (running) since Thu 2017-03-23 08:35:35 EDT; 10s ago
 Main PID: 1538 (memcached)
   CGroup: /system.slice/memcached.service
           └─1538 /usr/bin/memcached -m 64 -p 11211 -u memcache -l 127.0.0.1

Mar 23 08:35:35 trampamp systemd[1]: Starting memcached daemon...
Mar 23 08:35:35 trampamp systemd[1]: Started memcached daemon.
# telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.
stats
STAT pid 1538
STAT uptime 876
STAT time 1490273409
STAT version 1.4.21
STAT libevent 2.0.21-stable
STAT pointer_size 64
STAT rusage_user 0.025996
STAT rusage_system 0.006998
STAT curr_connections 5
STAT total_connections 8
STAT connection_structures 6
STAT reserved_fds 20
STAT cmd_get 0
STAT cmd_set 0
STAT cmd_flush 2
STAT cmd_touch 0
STAT get_hits 0
STAT get_misses 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT touch_hits 0
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 46
STAT bytes_written 15
STAT limit_maxbytes 67108864
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT malloc_fails 0
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT evictions 0
STAT reclaimed 0
STAT crawler_reclaimed 0
STAT lrutail_reflocked 0
END

4h0y avatar Mar 24 '17 00:03 4h0y

Is project dead?

r3b-fish avatar Apr 10 '17 08:04 r3b-fish

@4h0y Did you solve this problem? I have the same issue.

hammerwang666 avatar Nov 27 '17 12:11 hammerwang666

@zhenfan0753 I used a different port. For example 11212

4h0y avatar Nov 30 '17 18:11 4h0y

have same problem
changing port doesn't help
first i always receive error

Issue occured on server 127.0.0.1: 11211 {
 "server": "127.0.0.1:11211",
 "tokens": [ "11211",   "127.0.0.1" ],
 "messages": [ "object too large for cache" ],
 "failures": 5,
 "totalFailures": 0 
}

then several write operations succeed and then a shower of errors begin

set 'fingate/data_ready_8077bdd9c947d1df84630212e2c57574' '{"expTimeSeconds":30}' size: 259 Error: Server at 127.0.0.1: 11211 not available  
at Client.memcachedCommand[as command](/usr/local / nodejs8111 / lib / node_modules / memcached / lib / memcached.js: 306: 70)  
at Client.setters(/usr/local / nodejs8111 / lib / node_modules / memcached / lib / memcached.js: 936: 10)  
at Client.bowlofcurry[as set](/usr/local / nodejs8111 / lib / node_modules / memcached / lib / utils.js: 126: 15)  

funduck avatar Oct 17 '18 11:10 funduck

Looks like I got it!
this is how my memcached is started

memcached -p 11212 -m 256 -c 1024 -I 20m

and this was the client creation

new Memcached(
    options.host + ':' + options.port, {
        maxValue: 33554432
    }
);

when i corrected maxValue to the value <= 20Mb, for example 10485760
in logs instead of those unexpected errors i sometimes see for too big items

Error: The length of the value is greater than 10485760

which is perfectly fine and all other write operations succeed

funduck avatar Oct 17 '18 11:10 funduck

Any updates on this ?

deshmukhsanket avatar Apr 06 '20 04:04 deshmukhsanket

Can anyone help me out over this problem ?

deshmukhsanket avatar Apr 06 '20 04:04 deshmukhsanket

any updates on this ???!

Zorono avatar Jan 06 '21 17:01 Zorono

Any updates?

ezlo-lokoidav avatar Feb 11 '21 15:02 ezlo-lokoidav

We were getting this error (and also Connection readyState is set to readOnly) and it was due to the client hitting its default 5s timeout when the server was struggling under heavy load.

WilliamNurmi avatar May 07 '21 15:05 WilliamNurmi

@WilliamNurmi I get the same "Connection readyState is set to readOnly" during heavy loads.

Were you able to address this?

pkgarg avatar Apr 11 '22 17:04 pkgarg

Have you solved this problem now?I also encountered it

gesilaGRY avatar Jul 05 '22 06:07 gesilaGRY

Initialising the client like below fixed my problem:

new MemcachedClient(this.serverEndpoint, { maxValue: 10485760, timeout: 10 * 1000 /* 10 sec. */});

andrei-preeosoftware avatar Oct 10 '22 06:10 andrei-preeosoftware

I think I managed to consistently reproduce Error: Connection readyState is set to readOnly locally. Basically, you need memcached server running + stress test it with parallel writes. For me it starts to break at 40 parallel writes (but below I have it set to 100)

Considering that nothing else uses this memcached server & I have only one connection instance, I think its a library fault that it doesn't try to queue writes.. nor limit how many writes can do at a time & instead seems to just kill memcache.

Steps (using jest / integration test):

const MIN_FAILING_THREADS = 100;
it(`native memcache fails at ${MIN_FAILING_THREADS} concurrent writes`, async () => {
	const Memcached = require('memcached');

	// ACT
	const ops = [];

	const connection = new Memcached(['localhost:11211'], {
		// timeout: 500, the time after which Memcached sends a connection timeout (in milliseconds)
		timeout: 500,
		// retries: 5, the number of socket allocation retries per request.
		retries: 2,
		// failures: 5, the number of failed-attempts to a server before it is regarded as 'dead'.
		failures: 5,
		// retry: 30000, the time between a server failure and an attempt to set it up back in service.
		// the maximum size of the connection pool.
		poolSize: 200,
		// if true, authorizes the automatic removal of dead servers from the pool.
		remove: true,
		idle: 5000,
		maxValue: 524288, // default is 1048576
		encoding: 'binary',
	});

	connection.on('failure', async () => {
		console.error('Lost connection');
	});

	for (let i = 0; i < MIN_FAILING_THREADS; i++) {
		ops.push(
			new Promise((resolve, reject) => {
				connection.set(`x${i}`, i, 2, (err, result) => {
					if (err) {
						return reject(err);
					}

					return resolve(result);
				});
			}),
		);
	}

	// overload memcache
	Promise.all(ops);

	const result = await new Promise((resolve, reject) =>
		connection.getMulti(['x1'], (err, data) => {
			if (err) {
				reject(err);
			}

			resolve(data);
		}),
	);

	// ASSERT
        expect(result).toEqual({ x1: 1 });
});

tot-ra avatar Oct 14 '22 07:10 tot-ra

Install memcached in window works for my case.

https://stackoverflow.com/questions/59476616/install-memcached-on-windows

xoapit avatar Oct 19 '22 07:10 xoapit

It could be a memcached server problem. I see the problem from Java clients as well.

pkgarg avatar Oct 19 '22 16:10 pkgarg

Looks like I got it!
this is how my memcached is started

memcached -p 11212 -m 256 -c 1024 -I 20m

and this was the client creation

new Memcached(
    options.host + ':' + options.port, {
        maxValue: 33554432
    }
);

when i corrected maxValue to the value <= 20Mb, for example 10485760
in logs instead of those unexpected errors i sometimes see for too big items

Error: The length of the value is greater than 10485760

which is perfectly fine and all other write operations succeed

Thanks, you just saved my day

ken-kuro avatar Jun 06 '24 08:06 ken-kuro