8000 Connection timeout issues with memcached on AWS · Issue #99 · bradfitz/gomemcache · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Connection timeout issues with memcached on AWS #99

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

Closed
itsCodyBo opened this issue Apr 4, 2019 · 2 comments
Closed

Connection timeout issues with memcached on AWS #99

itsCodyBo opened this issue Apr 4, 2019 · 2 comments

Comments

@itsCodyBo
Copy link

Main Problem

My main issue is that I'm able to run a local instance of memcached on my machine and have it connect, write some key/value pairs, and read them back. However, when I try to pivot to doing the exact same process over a public facing AWS ubuntu instance with memcached installed and running, I get an almost immediate connection timeout error.

Theories?

I'm really not sure what the issue could be, I've been sure to check all AWS related network setting including VPCs, security groups, open ports, etc. I'm able to SSH into the machine and verify memcached is running but my connection still fails and I don't see a whole lot of logging information to go by.

I've provided my short code snippet below:

package main

import (
	"fmt"
	"math/rand"
	"strings"
	"time"

	"github.com/bradfitz/gomemcache/memcache"
)

func main() {

	const (
		// DefaultTimeout is the default socket read/write timeout.
		DefaultTimeout = 10000 * time.Millisecond

		// DefaultMaxIdleConns is the default maximum number of idle connections
		// kept for any single address.
		DefaultMaxIdleConns = 2
	)

	// fmt.Println(status)
	start := time.Now()

	// Connect to our memcache instance
	mc := memcache.New("172.31.33.237:11211")
	//mc := memcache.New("127.0.0.1:11211")
	mc.FlushAll()
	mc.Timeout = time.Second * 5 // Increase the client's timeout to 5 seconds

	//this will hold our keys so we can retrieve them later
	var keys []string

	// Setting multiple values
	for i := 0; i < 1; i++ {
		fmt.Println("formatting key")
		key := fmt.Sprintf("%s%d", "key", i)
		fmt.Println("generating value")
		value := strings.Repeat("#", rand.Intn(5+1))
		fmt.Println("pairing")
		mc.Set(&memcache.Item{Key: key, Value: []byte(value)})
		fmt.Println("adding to key list")
		keys = append(keys, key)
	}

	// Get multiple values
	fmt.Println("Getting errs")
	it, err := mc.GetMulti(keys)

	// // print errors if any
	// fmt.Println("Trying to print errs")
	// if err != nil {
	//     fmt.Println(err)
	//     return
	// }

	fmt.Println(err)

	// It's important to note here that `range` iterates in a *random* order
	for k, v := range it {
		fmt.Println("reading...")
		fmt.Printf("## %s => %s\n", k, v.Value)
	}
	elapsed := time.Since(start)
	fmt.Println("Total execution time: ", elapsed)

}

I've been fighting with this for a few days. I'm really hoping I can get some feedback on what could be causing this issue or how I can go about debugging it further.

@itsCodyBo
Copy link
Author

Also, I forgot to include the output:

formatting key
generating value
pairing
adding to key list
Getting errs
memcache: connect timeout to 172.31.33.237:11211
Total execution time:  10.101951142s

@bradfitz
Copy link
Owner

Sorry, I'm not able to help you debug your AWS configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0