Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stuck connecting #34

Closed
nsantini opened this issue Jul 13, 2017 · 7 comments
Closed

Stuck connecting #34

nsantini opened this issue Jul 13, 2017 · 7 comments

Comments

@nsantini
Copy link

nsantini commented Jul 13, 2017

Hi, I enabled Direct Line as a channel on the portal. Im using the npm botframework-directlinejs package to connect using the generated secret. The connection status gets stuck on Connecting.

Im taking the basic code from the README file in this repo, nothing added to it (NOTE cli.secret contains the generated secret):

var directLine = new DirectLine({
  secret: cli.secret
});

directLine.connectionStatus$
  .subscribe(connectionStatus => {
    switch(connectionStatus) {
      case ConnectionStatus.Uninitialized:    // the status when the DirectLine object is first created/constructed
        logger.debug('Status: Uninitialized');
        break;
      case ConnectionStatus.Connecting:       // currently trying to connect to the conversation
        logger.debug('Status: Connecting');
        break;
      case ConnectionStatus.Online:           // successfully connected to the converstaion. Connection is healthy so far as we know.
        logger.debug('Status: Online');
        postActivity();
        break;
      case ConnectionStatus.ExpiredToken:     // last operation errored out with an expired token. Your app should supply a new one.
        logger.debug('Status: ExpiredToken');
        break;
      case ConnectionStatus.FailedToConnect:  // the initial attempt to connect to the conversation failed. No recovery possible.
        logger.debug('Status: FailedToConnect');
        break;
      case ConnectionStatus.Ended:
        logger.debug('Status: Ended');
        break;
      default:
        logger.debug('Status: ', connectionStatus);
    }
  });
@billba
Copy link
Member

billba commented Jul 13, 2017

You have to either call postActivity or subscribe to activity$ to actually connect.

@nsantini
Copy link
Author

Doing both:

  directLine.activity$
    .subscribe(
      activity => process(activity),
      error => console.error("activity$ error", error)
    );
  
  directLine.postActivity({
          from: { id: 'myUserId', name: 'myUserName' }, // required (from.name is optional)
          type: 'message',
          text: "hi"
        }).subscribe(
          id => logger.debug("Posted activity, assigned ID ", id),
          error => logger.error("Error posting activity", error)
        );
  

@billba
Copy link
Member

billba commented Jul 13, 2017

Looks right to me. Have you tried creating a WebChat control and passing in the same secret?

@nsantini
Copy link
Author

I have WebChat enabled, and its working, tried the WebChat secret for DirectLine and still not working. Will try the DirectLine secret on the WebChat to double check that too

@nsantini
Copy link
Author

Confirmed WebChat works with either secret, but DirectLine doesn't work with either

@tobybrad
Copy link
Contributor

@nsantini Is this a pure Node app?

Take a look here to see if that helps you any: #29

@nsantini
Copy link
Author

thanks @tobybrad that's the issue, Im writing a node app, no dom present. Will follow up from that thread.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants