when we send an auth message to drupal, there are a bunch of error conditions we could handle up front, before we try to parse the response as json.

404 is the most obvious one - we should check the request headers, and if its not a 200, error out before JSON.parse() and set a more useful error.

CommentFileSizeAuthor
#7 autherrorreporting-1129718-4387912.patch521 bytesLSU_JBob

Comments

LSU_JBob’s picture

What kind of handling? I'm also getting a ton of 404 errors on the back-end even though I'm getting the desired behavior on the front-end. Should we just swallow 404's? or if 404 do not try and parse as JSON?

Anonymous’s picture

The latter - on 404, there's no point parsing the JSON, instead we can log a better error.

Anonymous’s picture

Version: 7.x-1.0-alpha5 » 7.x-1.0-alpha6

first commit here:

http://drupalcode.org/project/nodejs.git/commit/6a5d146

leaving open, i think there's more to do.

LSU_JBob’s picture

I've pulled this down and the error messages I'm getting when trying to hit the auth path are a lot friendlier:

23 Apr 17:55:36 - Client 8481339609716088 connected
Authenticating client with key "1fc52d3dc7c8129889b09c06831ae74f"
Backend authentication url not found.

Perhaps spit out a little more info about what the auth path it's trying to use when the error "Backend authentication url not found."?

I'm having this problem with it never being able to find a backend authentication and I'm trying to debug it.

Anonymous’s picture

i pushed up some better debugging info, pull the latest code and let me know how you go.

LSU_JBob’s picture

This is great, I'm still not able to authenticate but now I have a nice clean debug message after every unsuccessful attempt:

25 Apr 00:21:52 - Client 9066404353361577 connected
Authenticating client with key "55ff6ef86271d8260c5aa8cb97fc092d"
Backend authentication url not found, tried using these options: 
{ port: '80',
  host: 'localhost',
  path: '/var/www/docroot/nodejs/auth/55ff6ef86271d8260c5aa8cb97fc092d',
  method: 'GET',
  agent: 
   { options: { host: 'localhost', port: '80' },
     host: 'localhost',
     port: '80',
     queue: [],
     sockets: [ [Object] ],
     maxSockets: 5 } }

I really like this, but perhaps we should only show it if backendSettings.debug is true.

I will roll a patch now to wrap your console.log(options) in the same way you do your other error reporting.

LSU_JBob’s picture

StatusFileSize
new521 bytes

Here it is

Anonymous’s picture

Status: Active » Fixed

works for me, slightly modified version of your patch committed here:

http://drupalcode.org/project/nodejs.git/commit/8dc44c6

thanks again.

Anonymous’s picture

oh yeah, it looks like you've got the filesystem path rather than the url path, in case you hadn't already figured that out.

LSU_JBob’s picture

What should I put in for my auth path?

Right now my config is:

"host":"localhost",
"authPath":"/var/www/docroot/nodejs/auth/"

Should authPath be a URL?

LSU_JBob’s picture

figured it out! Auth is working for me!

bigsyke’s picture

how did you get this working?"

LSU_JBob’s picture

bigsyke, i had to make sure my auth path was correct, for my sandbox i have [IP address]/drupal7

so my auth path was /drupal7/auth, also double check the format of nodejs.config.js

bigsyke’s picture

Sweet man, got it. Thank you!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

  • Commit 6a5d146 on 6.x-1.x, 7.x-1.x, drupalconlondon, auth-refactor, 8.x-1.x, 8.x-1.x-head by beejeebus:
    #1129718: handle auth better.
    
    
  • Commit 8dc44c6 on 6.x-1.x, 7.x-1.x, drupalconlondon, auth-refactor, 8.x-1.x, 8.x-1.x-head by beejeebus:
    #1129718 by LSU_JBob: only show detailed auth 404 info if debug is...