Baby steps: problem with safeApp.connectAuthorised()

Can anyone help me with this as I can’t see what might be wrong?!

The code is a website, currently on Test19 at safe://myfd.rsports. After loading, click the blue SAFE icon (top right).

At the call to safeApp.connectAuthroised() I get an error:

Error: Unexpected (probably a logic error): Could not connect to the SAFE Network

The authUri I have seems very long (several full screen width lines), so I wonder if there’s a problem with that but as the error happens afterwards it is probably ok.

Here is a code fragment, but if you load safe://myfd.rsports you can debug it directly:

      window.safeApp.initialise(self.appKeys).then((appHandle) => {
        RS.log('SAFEApp instance initialised and appHandle returned: ', appHandle);
        
        window.safeApp.authorise(appHandle, self.appKeys.permissions, self.appKeys.options)
        .then((authUri) => {
          RS.log('SAFEApp was authorised and authUri received: ', authUri);
          window.safeApp.connectAuthorised(appHandle, authUri)
          .then(_ => {
            RS.log('SAFEApp was authorised & a session was created with the SafeNetwork');
                   
            self.configure({ 
              appHandle:      appHandle,                 // safeApp.initialise() return (appHandle)
              authURI:        authUri,                  // safeApp.authorise() return (authUri)
              permissions:    self.appKeys.permissions, // Permissions used to request authorisation
              options:        self.appKeys.options,     // Options used to request authorisation
            });

          }, function (err){
            self.reflectNetworkStatus(false);
            RS.log('SAFEApp SafeNetwork Connect Failed: ' + err);
          });

        }, function (err){
          self.reflectNetworkStatus(false);
          RS.log('SAFEApp SafeNetwork Authorisation Failed: ' + err);
        });

      }, function (err){
          self.reflectNetworkStatus(false);
          RS.log('SAFEApp SafeNetwork Initialise Failed: ' + err);
      });      
1 Like

That error is reported already here https://safenetforum.org/t/maidsafe-dev-update-august-31-2017-test-19/15974/48 and the tracker is here MAID-2321

Thanks - I saw that earlier but didn’t realise it was similar.

@hunterlester my error isn’t intermittent, so if it is the same as this issue my code at safe://myfd.rsports might help with debugging (assuming its the same issue).

1 Like

If I run @Joseph_Meagher’s whole code snippets from his sites all at once I get an error every time, if I however just run connectAuthorised by itself after having initialised and authorised then the error is intermittent.

2 Likes

Just to keep everyone updated, we are actively working on MAID-2321 which seems to be the issue most of the people are having when they see the error Error: Unexpected (probably a logic error): Could not connect to the SAFE Network.
At the moment we suspect that when the browser is closed, under some circumstances, the connections are not closed gracefully therefore new attempts to connect when opening or launching applications the max number of clients allowed (currently 4) per IP is reached. We are researching and testing ways to handle that so they get closed graccefully. Good news is that there is no evidence of connections leakage from the browser/plugins.

EDIT: for those hitting this issue too often, in the meantime, you should be able to work-around it by closing the browser (and any other safe app) and waiting for > 160 secs. before launching it again, that’s the time it takes the proxies (I think in the worst case) to free these connections.

7 Likes

This topic was automatically closed after 60 days. New replies are no longer allowed.