You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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
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:
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.
The text was updated successfully, but these errors were encountered: