barisusakli / nodebb-plugin-imgur

A plugin that uploads images to imgur
17 stars 19 forks source link

502 bad gateway error Nginx after upgrading to version 1.0.0 #11

Closed henrywright closed 9 years ago

henrywright commented 9 years ago

Since upgrading to version 1.0.0 (from 0.1.4) I'm unable to upload images. I get a 502 bad gateway error. Also, here's the error message I get when running tail /var/log/nginx/error.log

2015/08/13 17:32:03 [error] 26028#0: *446 upstream prematurely closed connection while reading response header from upstream, client: 92.24.92.254, server: example.com, request: "POST /api/post/upload HTTP/1.1", upstream: "http://127.0.1.1:4567/api/post/upload", host: "example.com", referrer: "https://example.com/topic/11/topic-name/9"
barisusakli commented 9 years ago

Whats in the nodebb logs? Also did you go tru the setup process detailed in the readme?

henrywright commented 9 years ago

Yes, I created a new Imgur app and went through the readme steps. What is the command to output the NodeBB logs? I'll copy them to here

barisusakli commented 9 years ago

./nodebb log in your nodebb directory then try to upload an image and see what happens. the file is in logs/output.log

henrywright commented 9 years ago

Thanks, this is the entire NodeBB log output:

error: Unable to parse Imgur json response. [<html><body><h1>504 Gateway Time-out</h1>
The server didn't respond in time.
</body></html>
] Unexpected token <
13/8 18:13 [26374] - error: [plugins] filter:uploadImage,  Unexpected token <
barisusakli commented 9 years ago

That usually means imgur is not responding. I just tested with 1.0.0 and it worked for me.

henrywright commented 9 years ago

Yes, it seems it wasn't responding when I tried to upload that first time. I just tried uploading a test image again and got this in the logs:

13/8 18:51 [26674] - error: TypeError: Cannot call method 'hasOwnProperty' of undefined
    at appendFormValue (nodebb/node_modules/request/request.js:340:17)
    at Request.init (nodebb/node_modules/request/request.js:354:11)
    at new Request (nodebb/node_modules/request/request.js:140:8)
    at request (nodebb/node_modules/request/index.js:55:10)
    at Function.post (nodebb/node_modules/request/index.js:63:12)
    at refreshToken (nodebb/node_modules/nodebb-plugin-imgur/index.js:87:11)
    at Request._callback (nodebb/node_modules/nodebb-plugin-imgur/index.js:189:13)
    at Request.self.callback (nodebb/node_modules/request/request.js:198:22)
    at Request.EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (nodebb/node_modules/request/request.js:1057:14)
barisusakli commented 9 years ago

Published 1.0.1 with better error messages give that one a try.

Also check your database for the key nodebb-plugin-imgur It should have access_token, refresh_token etc.

henrywright commented 9 years ago

Update: I just uninstalled 1.0.0 and installed 0.1.4 and the problem disappeared. I can now upload images again.

henrywright commented 9 years ago

Update 2: I reinstalled 1.0.0 and noticed my Imgur secret doesn't seem to be saving in Installed Plugins > Imgur. Perhaps that's the issue?

If I enter the client ID, then enter the secret, then click save and then navigate away from the page, when I go back to Installed Plugins > Imgur, the secret is missing from the text box.

barisusakli commented 9 years ago

That sounds like a cache issue, install 1.0.0 clear cache try again. 0.1.4 doesn't have a secret field

henrywright commented 9 years ago

That sounds like a cache issue, install 1.0.0 clear cache try again. 0.1.4 doesn't have a secret field

I'm actually testing in 1.0.0 again now. I just cleared my cache and the secret still doesn't save. I think that could be the problem.

barisusakli commented 9 years ago

Give 1.0.2 a try.

henrywright commented 9 years ago

1.0.2 doesn't seem to be available in the NodeBB admin area. What's the recommended way to upgrade via the terminal?

barisusakli commented 9 years ago

npm i nodebb-plugin-imgur will do.

henrywright commented 9 years ago

Success! Many thanks for your help. Working perfectly now. No errors in the logs either.

barisusakli commented 9 years ago

No problem :)