Announcement Announcement Module
Collapse
No announcement yet.
Social App is working locally, only Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Social App is working locally, only

    Hi All,

    I've built an application using Spring Social (Facebook and Twitter). It's working fine locally, I mean, accessing localhost. When I deployed it to then real domain application, it stopped to work.

    Issue occours after I provide the credentials (both Twitter and Facebook) to connect, looks like this issue is with regards the URL Callback. How come it works properly using localhost and it has a different behaviour in production? Does anyone have any clue? Didn't find anything looking into the logs.

    Maybe I missed something. Any clue will be very welcome.

  • #2
    What exactly is the problem? Does it do the wrong callback? Is there a stack trace? There are a number of things that could be different between production and development on localhost. You indicate that you think it's an issue with the URL callback? What makes you think that? What does the callback look like and how does that compare with how your application is deployed?

    Comment


    • #3
      Thanks for the prompt reply!

      Problem: web application is working perfectly locally, but it's not in production. Actually, it looks connected to Facebook/Twitter and after that, returning to an invalid URL:

      HTTP Status 404/ssconnect/twitter
      [mydomain.com]/ssconnect/twitter?oauth_token=Q9.........

      I don't have a stack trace, looks like it's redirecting to an invalid page, no errors in the logs.

      I'm using a Grails Plugin named spring-social-facebook.

      Can you give me some clue? Where do you think I need to check? Any specific configuration?

      - - - x - - -

      One thing I though strange was the method addConnection(Connection<?> connection) in JdbcConnectionRepository class, I could see a query like below in addConnection method:

      int rank = jdbcTemplate.queryForInt("(select coalesce(max(rank) + 1,1) as rank from . . . . . . . . .

      Any reason for this "(" before the select clause? ? It's causing "Invalid SQL error" on Firebird 2.+ database.

      Thank you

      Comment


      • #4
        One thing that immediate hit me is that the callback has "ss" in front of "connect". Where did the "ss" come from?

        Also, since this is at some domain, is it public? Can I see it and try it myself?

        Comment


        • #5
          Hi - "ssconnect" comes from the plugin mapping, I think we "ss" stand for spring-social. Do you think the above addConnection method can cause the issue in production only? I had to re-implement it due to that extra "(" on the query clause. At least in localhost it's working fine, only think I did was get rid the parenteses.

          Domain is not public yet, but only thing you will see are the steps below to face the issue:

          1 - click in connect facebook icon
          2 - then Facebook will show the login screen
          3 - I inform my credentials, it connects
          4 - finally, I got HTTP status 404 pointing to [mydomain.com]/ssconnect/twitter?oauth_token=Q9.........

          No problem to give you access, can you send me a private message?

          This is happening only in production, I can use the integration perfectly locally using localhost as web server.

          Thanks.

          Comment


          • #6
            Well, ConnectController listens for "/connect/{providerId}", as evidenced by this snippet:

            Code:
            @Controller
            @RequestMapping("/connect")
            public class ConnectController {
               ...
            }
            So, "ssconnect" won't match anything. I am a little curious about how you've configured ConnectController and DispatcherServlet, to better understand how this URL came about. In the ConnectController configuration, do you set the applicationUrl property? Is there any bit of the ConnectController and DispatcherServlet configuration you can share here to help me understand what's going on?

            Also, as I said, is there a live URL that I can go to and try this out?

            As for the extra "(", that shouldn't cause the problem you're having (I'd think you'd get a 500 Internal Server error instead of a 404). That said, I'm not sure why those parentheses are there. They don't cause any trouble with other DBs, but I'm not sure they do anything useful, either. I'll look into removing them.

            Comment


            • #7
              Hmmmm, let me check it out the applicationUrl property tonight. Thanks for removing the "(", I took sometime to figure out this issue and I'm pretty sure that this will help a lot - at least for the Firebird database lovers like me.

              Please find where "ssconnect" comes from:

              Code:
              class SpringSocialUrlMappings {  
              static mappings = {    
                  //TODO: Document this UrlMappings    
                  name springSocialConnect: "/ssconnect/$providerId/$providerUserId?" {      
                  controller = 'springSocialConnect'      
                  action = [GET: "oauthCallback", POST: 'connect', DELETE: "disconnect"]    
                  }    
                  name springSocialSignIn: "/sssignin/$providerId/$providerUserId?" {      
                  controller = 'springSocialProviderSignIn' action = [GET: "oauthCallback", POST: 'signin']    
                  }
                }
              }
              * provided by the Grails Plugin (spring-social-facebook)

              Let you know if any luck.

              Thanks.

              Comment


              • #8
                Ahhhh...I completely missed the part earlier where you said this is a Grails plugin.

                Honestly, I've never tried out the Spring Social Grails plugin (perhaps it's time that I did, though), so I'm not sure how much help I'll be beyond the Spring Social-specific issues.

                That said, is there a reason you mapped it to "/ssconnect/$providerId/$providerUserId?" ? Was that a choice you made or a choice made by the plugin? I'm guessing that it's a choice you made (or else the plugin is doing some interesting stuff under the covers that I need to understand better).

                Assuming I'm right and the Grails plugin isn't doing anything strange with how ConnectController responds to requests, then I can assure you that "/ssconnect/..." *will not* work and will give you a 404 like you saw. ConnectController responds only to URLS beginning with "/connect". (Again, assuming that the plugin isn't doing some other magic.) Before you start messing with applicationUrl, try changing you config so that it's "/ssconnect" and "sssignin" and let me know if that makes any difference for you.

                In the meantime, I might go take a look at that plugin. :-)

                Comment


                • #9
                  Also, to be sure we're talking about the same plugin: Are you using the Spring Social plugin by SynergyJ? Or is it some other plugin?

                  Comment


                  • #10
                    Yes, that's the plugin. Very poor documentation to this plugin, but it helps. I'm performing some tests now in my application. Will keep you posted.

                    Cheers.

                    Comment


                    • #11
                      FWIW, I'm now convinced that the plugin behaves differently, providing its own controllers (at least one of which *does* respond to /ssconnect requests). That said, I still don't have it working even locally. So I've emailed the author of the plugin and asked him to chime in if he can.

                      Comment


                      • #12
                        No luck so far, changed ssconnect to connect, just to make sure. Also defined the applicationUrl properly (it was null before), got the same problem. Only difference is now I can see:

                        [my real domain]/connect/twitter?oauth_token=GnptYo8FB............

                        * after do the above changes, application is still working properly as localhost.

                        ..

                        Comment


                        • #13
                          Yeah, I've been digging into the plugin and /ssconnect is the right path. In fact, that plugin isn't even using the same ConnectController provided by Spring Social. It provides its own SpringSocialConnectController (which is a Groovy port of Spring Social's controller--see https://github.com/synergyj/grails-s...troller.groovy).

                          This makes this less of a Spring Social issue and more of an issue with that plugin. Sorry to say I won't be much help here until I get my head around how that plugin works. Hopefully Domingo will get my email and offer some assistance.

                          Comment


                          • #14
                            No worries mate. I'm still investigating here. I found that GrailsConnectSupport extends ConnectSupport. It should be a minor configuration in my application to run in production. If I have luck, let you know.

                            Cheers!

                            Comment


                            • #15
                              After enable log level as DEBUG in production:

                              Code:
                              java.lang.NullPointerException at SpringSocialConnectController$_closure2.doCall(SpringSocialConnectController.groovy:89)
                                      at SpringSocialConnectController$_closure2.doCall(SpringSocialConnectController.groovy)
                                      at grails.plugin.springcache.web.GrailsFragmentCachingFilter.doFilter(GrailsFragmentCachingFilter.groovy:66)
                                      at net.sf.ehcache.constructs.web.filter.Filter.doFilter(Filter.java:86)
                                      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
                                      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
                                      at java.lang.Thread.run(Thread.java:679)
                              This should be the reason of the issue. Will try to debug this now.
                              Last edited by dinizssa; Jan 9th, 2012, 07:54 PM.

                              Comment

                              Working...
                              X