none
[Node.js][Mobile Apps] "Unexpected connection failure. 0" loading test ToDoList with authencation RRS feed

Answers

  • Is that the security reason or you have forgotten to init MobileServiceClient "client" in your code at https://github.com/KayJayThree/stengel001/blob/master/www/js/index.js#L22?

    You need to init the client first:

    function onDeviceReady() {
            // Create a connection reference to our Azure Mobile Apps backend
            client = new WindowsAzure.MobileServiceClient('https://<your_mobile_app_name>.azurewebsites.net'); 
            todoItemTable = client.getTable('todoitem');
            client.login('google')
                .then(function () {
    
                    // BEGINNING OF ORIGINAL CODE
    
                    // Refresh the todoItems
                    refreshDisplay();
    
                    // Wire up the UI Event Handler for the Add Item
                    $('#add-item').submit(addItemHandler);
                    $('#refresh').on('click', refreshDisplay);
    
                    // END OF ORIGINAL CODE
    
                }, handleError);
        }


    Wednesday, March 9, 2016 7:10 AM
    Moderator
  • Your code misses right bracket of the function onDeviceReady(), add "}" under the sentence at https://github.com/KayJayThree/stengel001/blob/master/www/js/index.js#L62. Then I used your "index.js" and "index.html" in my test project, it worked fine on my side. 

    You can start with a new quick start project and follow the steps on guide for a clear test.

    • Marked as answer by Ron Stengel Thursday, March 10, 2016 7:06 AM
    • Unmarked as answer by Ron Stengel Thursday, March 10, 2016 7:06 AM
    • Marked as answer by Ron Stengel Thursday, March 10, 2016 7:35 AM
    Wednesday, March 9, 2016 9:41 AM
    Moderator

All replies

  • I turned Auth off and then changed the tables to no auth as well, and it is working again.  So something is wrong with my auth, neither AD nor Facebook auth work so will have to try it again.
    Monday, March 7, 2016 10:32 AM
  • How are you running your application?  On Ripple, on an emulator or on a real device?

    Is this the "QuickStart" Cordova project?

    Have you tried other authentication mechanisms?

    Could you post the relevant configurations, for your Facebook application registration, your Mobile Apps Authentication (leave out client secrets), plus relevant auth code?

    Monday, March 7, 2016 7:22 PM
  • I have tried Ripple, Android, and device and all are the same.  Yes, it is the QuickStart Cordova Project.

    I tried AD auth and got same error. I was thinking I can go through it again. 
    There are not a lot of step by step guides for Cordova and VS2015 so not a lot of options. This seems pretty complete though.

    I will go through process again and if I get stuck on same I will repost. 

    Thanks for responding.
    Tuesday, March 8, 2016 5:26 AM
  • If you use Visual Studio Tools for Apache Cordova in VS to develop Cordova applications, you may found the similar error message when you get "Unexpected connection failure. 0":

    Refused to connect to 'https://www.facebook.com/dialog/oauth?response_type=code&client_id=<client_id>&redirect_uri=https%3A%2F%2F<mobile_app_name>.azurewebsites.net%2F.auth%2Flogin%2Ffacebook%2Fcallback&state=nonce%3D918a25d562ff441bbe8a2506d61e7926_20160308055030%26redir%3D%2Ftables%2Ftodoitem%3F%24filter%3D(complete%2520eq%2520false)' because it violates the following Content Security Policy directive: "default-src 'self' data: gap: https://<mobile_app_name>.azurewebsites.net". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.

    If so, we need to add the facebook OAuth host in meta tag in header tag. E.G.

    <meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://www.facebook.com https://<mobile_app_name>.azurewebsites.net; style-src 'self'; media-src *">

    Refer to https://azure.microsoft.com/en-us/documentation/articles/app-service-mobile-cordova-get-started-users/#add-authentication for more.

    Any concern, please feel free to let me know.


    Tuesday, March 8, 2016 6:03 AM
    Moderator
  • Hello Gary,

    This is exactly what is happening in the logs "...Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback." as you mention in your reply. I removed and setup the Facebook auth again, only to receive the same message so working on a fix now.

    Thanks for reply...

    Wednesday, March 9, 2016 2:08 AM
  • You only need to add "https://www.facebook.com" after "data: gap: " in mete tag.

    Have you solved your issue?

    Wednesday, March 9, 2016 2:20 AM
    Moderator
  • Okay so I have done everything suggested, and still getting the message so I decided to try Google.  At this point I have added auth for Ad, Facebook, and Google and all give same error so this must be something other than the provider; but I have gone over the entire list of instruction three times now, and still getting the message

    "Unexpected connection failure."

    So not sure what to try at this point. Any other suggestions?

    Thanks

    Wednesday, March 9, 2016 4:47 AM
  • Yes, I tried this, and it still failed.  Code is currently set for Google but I did add the facebook entry prior.

    https://github.com/KayJayThree/stengel001.git

    Wednesday, March 9, 2016 6:32 AM
  • Is that the security reason or you have forgotten to init MobileServiceClient "client" in your code at https://github.com/KayJayThree/stengel001/blob/master/www/js/index.js#L22?

    You need to init the client first:

    function onDeviceReady() {
            // Create a connection reference to our Azure Mobile Apps backend
            client = new WindowsAzure.MobileServiceClient('https://<your_mobile_app_name>.azurewebsites.net'); 
            todoItemTable = client.getTable('todoitem');
            client.login('google')
                .then(function () {
    
                    // BEGINNING OF ORIGINAL CODE
    
                    // Refresh the todoItems
                    refreshDisplay();
    
                    // Wire up the UI Event Handler for the Add Item
                    $('#add-item').submit(addItemHandler);
                    $('#refresh').on('click', refreshDisplay);
    
                    // END OF ORIGINAL CODE
    
                }, handleError);
        }


    Wednesday, March 9, 2016 7:10 AM
    Moderator
  • Thanks again for replying, I appreciate your help.  I changed the code;

    https://github.com/KayJayThree/stengel001.git

    Getting the same error so tried on Facebook and still getting same.

    I added

    client = new WindowsAzure.MobileServiceClient('https://<your_mobile_app_name>.azurewebsites.net');

    also noticed your code has the following prior to client.login(); so I tried before and inside function and same both ways.

    todoItemTable = client.getTable('todoitem');

    Attaching image of error

    Wednesday, March 9, 2016 7:48 AM
  • Your code misses right bracket of the function onDeviceReady(), add "}" under the sentence at https://github.com/KayJayThree/stengel001/blob/master/www/js/index.js#L62. Then I used your "index.js" and "index.html" in my test project, it worked fine on my side. 

    You can start with a new quick start project and follow the steps on guide for a clear test.

    • Marked as answer by Ron Stengel Thursday, March 10, 2016 7:06 AM
    • Unmarked as answer by Ron Stengel Thursday, March 10, 2016 7:06 AM
    • Marked as answer by Ron Stengel Thursday, March 10, 2016 7:35 AM
    Wednesday, March 9, 2016 9:41 AM
    Moderator
  • Thanks again for replying!!!

    First, I am not sure why the missing curly bracket "}" did not show an alert or warning; strange. But something to keep in mind as I use program.

    I made the change and it did not work when using "Nexus 5X API 23" which is the current Android Virtual Device. Frustrated at this point, I re-built the app, cleared cache etc etc. Still not working.

    I then pushed it to my Android device and it worked. Seeing Facebook login for the first time. After much frustration it is working...

    Thanks again for responding and not giving up.

    Cheers

    Ron

    Thursday, March 10, 2016 7:35 AM
  • It seems Android Virtual Device has some limitation. And I am using Visual Studio Emulator for Android for debugging and testing. It seems doesn't have such issue.

    Whatever, it's glad to see you have fixed the issue. Congratulations.

    Thursday, March 10, 2016 7:47 AM
    Moderator