Skip to content
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

PermanentRedirect? #178

Open
tj opened this issue May 16, 2013 · 28 comments
Open

PermanentRedirect? #178

tj opened this issue May 16, 2013 · 28 comments

Comments

@tj
Copy link
Contributor

tj commented May 16, 2013

yo @domenic, updating from 0.5.x to 0.8.x and now im getting this for each request, I didn't notice anything that seemed related in the changelog, any idea?

<Error><Code>PermanentRedirect</Code><Message>The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.</Message><RequestId>86C86A0AFCB5795E</RequestId><Bucket>i.cloudup.com</Bucket><HostId>KowqHiRPuWlEG9o05aImJ3dMbzScbabmEW+ltRiaovKqrs6Hn0wvS15l07vdVZbw</HostId><Endpoint>i.cloudup.com.s3.amazonaws.com</Endpoint></Error>
@tj
Copy link
Contributor Author

tj commented May 16, 2013

0.7.1 seems fine

@domenic
Copy link
Contributor

domenic commented May 16, 2013

Is it for a bucket you just created?

@tj
Copy link
Contributor Author

tj commented May 16, 2013

nope it's at least 8+ months old

@domenic
Copy link
Contributor

domenic commented May 16, 2013

OK what does your constructor look like; a few options underwent minor changes e.g. domain got killed in favor of endpoint being more accurate and such.

@tj
Copy link
Contributor Author

tj commented May 16, 2013

this one is:

var client = knox.createClient({
  key: conf['s3 key'],
  secret: conf['s3 secret'],
  bucket: conf['s3 bucket']
});

@domenic
Copy link
Contributor

domenic commented May 16, 2013

Oh the bucket has periods in its name hmm it's probably trying to auto-switch you to path style, which should work but I guess isn't working :-/. You can force it back with style: "virtualHosted" maybe?

@domenic
Copy link
Contributor

domenic commented May 18, 2013

Did that fix it? Now I'm unhappy that I broke backward compat, not sure how to best make this right.

@tj
Copy link
Contributor Author

tj commented May 18, 2013

nope :( i just reverted to an older version for now 0.7.x

@domenic
Copy link
Contributor

domenic commented May 20, 2013

Try 0.8.1, found something that probably fixed it in 2400475.

@tj
Copy link
Contributor Author

tj commented May 24, 2013

still no luck :(

@domenic
Copy link
Contributor

domenic commented May 24, 2013

I hate that this stuff isn't reproducible. If you're up for it, try doing console.log(options) inside Client.prototype.request on both 0.7.x and 0.8.x; that was pretty helpful over in #66 (comment).

@tj
Copy link
Contributor Author

tj commented May 24, 2013

im getting the following, not sure why it's saying i.cloudup.com for this one haha, that's not the right bucket, we do have others with that bucket though

{ options: 
   { key: '...',
     secret: '...',
     bucket: 'cloudup-avatars',
     region: 'us-west-1' },
  secure: true,
  host: 'cloudup-avatars.s3-us-west-1.amazonaws.com',
  urlBase: 'cloudup-avatars.s3-us-west-1.amazonaws.com',
  agent: false,
  key: '....',
  secret: '...'
  bucket: 'cloudup-avatars',
  region: 'us-west-1',
  style: 'virtualHosted',
  endpoint: 's3-us-west-1.amazonaws.com',
  url: [Function] }

/home/vagrant/projects/cloudup/.rnpm/node_modules/knox/lib/client.js:228
        throw new Error('Outside of the us-standard region, bucket names must'
              ^
Error: Outside of the us-standard region, bucket names must be DNS-compliant. The name "i.cloudup.com" does not consist of valid period-separated labels.

@domenic
Copy link
Contributor

domenic commented May 24, 2013

Wait wtf, that shouldn't be possible, it uses options.bucket directly inside that error string.

Anyway I meant the request options inside Client.prototype.request instead of the client options inside the constructor.

@tj
Copy link
Contributor Author

tj commented May 24, 2013

i did notice that it merges right to the options object (i think), maybe that manip is playing some role, though we do pass a new object each time so that's odd. ill check that out in a bit

@domenic
Copy link
Contributor

domenic commented May 24, 2013

Hmm yeah maybe I shouldn't mess with the options object passed in, that was kind of dumb.

@tj
Copy link
Contributor Author

tj commented May 24, 2013

I've done similar in Express :D it's usually fine, I dont think that's the real problem here but that output vs options does seem a little odd, at first I thought maybe there was a global leak

@domenic
Copy link
Contributor

domenic commented Jun 9, 2013

0.8.3 no longer messes with passed options object, FWIW.

@psugihara
Copy link

@visionmedia, any chance the endpoint was in us-west-2 (oregon)?

I'm seeing this issue as well and according to this, s3.amazonaws.com only works for us-east and us-west-1:
http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region

I think that makes the knox docs incorrect.

@adriancooney
Copy link

@psugihara seems to be correct. Buckets not in US Standard have to be access via [bucket name].s3.amazonaws.com instead of s3.amazonaws.com/[bucket name]. S3 serves the redirection error otherwise.

@AnthonyAkentiev
Copy link

@adriancooney @psugihara

I've got same problem with 301 REDIRECT reply while trying to upload file using Knox.
I tried many times, but still can not upload file.
However - uploading with my GUI utility (3Hub) works fine with same credentials.

I do:

client.putFile('my.json', '/user.json', function(err, res){
  // and res.statusCode is always 301 here...
});

My region for EC2 instances is Ireland, but it seems like S3 has no region set ("S3 does not requires region").

Can you please help me to fix the issue?

@AnthonyAkentiev
Copy link

UPDATE: Oh yes.
Once i have created bucket in US Standard - everything went OK!

Still my Ireland bucket does not work ((( Is that a bug?

@AnthonyAkentiev
Copy link

Yes. Unfortunately, knox does not automatically handle redirects to different endpoints.

The solution is to set 'region' option to 'eu-west-1'.

@mihneasim
Copy link

I chose dev bucket to be Ireland, so it's closer to me. Thanks guys for clearing this redirection out. Still on in 0.9.2
I would have expected aws to write a Location header, but it doesn't. (i don't see it on response object)

@PedroSena
Copy link

@AnthonyAkentiev When you say "The solution is to set 'region' option to 'eu-west-1'." Where should this be set ? I'm trying to do this on knox.createClient arguments but it does not work too

@AnthonyAkentiev
Copy link

@PedroSena, add region option like this:

 var client = knox.createClient({
      key: config.get('s3:key') 
      , secret: config.get('s3:secret')
      , bucket: config.get('s3:bucket')
      , region: config.get('s3:region')    // eu-west-1
 });

@PedroSena
Copy link

Thanks, I tried that but didn't work, still getting the redirect error, I'm migrating my bucket to a US Standard

@AnthonyAkentiev
Copy link

@PedroSena, please tell us if it will help you.

@PedroSena
Copy link

Yes, migrating the bucket to a US Standard one(was on Oregon before) worked, not the best path(had to migrate 30k files) but at least it is working now

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

No branches or pull requests

7 participants