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

I'm having trouble connecting to the server, please refresh the page #224

Closed
dandresv opened this issue Feb 4, 2019 · 18 comments
Closed
Assignees
Labels

Comments

@dandresv
Copy link

dandresv commented Feb 4, 2019

I have problems with my credentials since, I follow all the steps that indicate but it always answers me the following when I execute the command line npm start

"I'm having trouble connecting to the server, please refresh the page"

Attached url with some images of my credentials https://drive.google.com/drive/folders/1mwT8pzuU7EGQkOn8TJiR1yUmZ06I_gwB?usp=sharing

@obgvts
Copy link

obgvts commented Feb 4, 2019

I'm having the same issue. Seems to come from /api/session, https error code 404 - Not found. No idea what is not found.

I'm pretty sure nothing wrong with my apikey, aim_url, assistant_id. Tested them on rest tester.

@Oliver-I
Copy link
Contributor

Oliver-I commented Feb 4, 2019

@stevenpkg Can you take a look at this?

@stevenpkg
Copy link

stevenpkg commented Feb 4, 2019

@dandresv looking at your .env file I can see you have both username, password and IAM key. Please specify one or the other. Use a # to comment out variables you do not need:

#ASSISTANT_USERNAME=6a563286-afc2-49b8-9214-xxxxxxxxxx
#ASSISTANT_PASSWORD=d8T7Hxxxxxxx
#ASSISTANT_URL=https://gateway.watsonplatform.net/assistant/api

# OR IAM API key and URL

ASSISTANT_IAM_APIKEY=0adu5bk5RDQQqnWtxRufmST0dJlAnZv-xxxxxxxxxxxx
ASSISTANT_IAM_URL=https://gateway.watsonplatform.net/assistant/api

@dandresv
Copy link
Author

dandresv commented Feb 5, 2019

@stevenpkg Make the corresponding changes and leave these variables ASSISTANT_ID, ASSISTANT_IAM_APIKEY, ASSISTANT_IAM_URL and I still get the same error, I'm reviewing from the browser console and I answered the following "Failed to load resource: the server responded with a status of 500 (Internal Server Error) ": 3000 / api / message

@stevenpkg
Copy link

stevenpkg commented Feb 6, 2019

@dandresv the problem I believe is getting the session key due to credentials not being correct. What error is printed on the backend.

put some debug code around this function, also you can turn on node debug

NODE_DEBUG=request npm start
app.get('/api/session', function (req, res) {
  assistant.createSession({
    assistant_id: process.env.ASSISTANT_ID || '{assistant_id}',
  }, function (error, response) {
    if (error) {
      return res.send(error);
    } else {
      return res.send(response);
    }
  });
});

@dandresv
Copy link
Author

dandresv commented Feb 7, 2019

This is the error that is showing me in the app.js.

(api/session)
Error: Not Found
at Request._callback (\assistant-simple\node_modules\watson-developer-cloud\lib\requestwrapper.js:102:21)
at Request.self.callback (\assistant-simple\node_modules\watson-developer-cloud\node_modules\request\request.js:185:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request. (\assistant-simple\node_modules\watson-developer-cloud\node_modules\request\request.js:1157:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at Gunzip. (\assistant-simple\node_modules\watson-developer-cloud\node_modules\request\request.js:1079:12)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
code: 404,
error: 'Not Found',
'x-global-transaction-id': 'ffea405d5c5c49b130e9497d'

assistant.message
Error: Missing required parameters: session_id
at Object.getMissingParams (\assistant-simple\node_modules\watson-developer-cloud\lib\helper.js:95:11)
at AssistantV2.message (\assistant-simple\node_modules\watson-developer-cloud\assistant\v2.js:178:38)
at \assistant-simple\app.js:89:13
at Layer.handle [as handle_request] (\assistant-simple\node_modules\express\lib\router\layer.js:95:5)
at next (\assistant-simple\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (\assistant-simple\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (\assistant-simple\node_modules\express\lib\router\layer.js:95:5)
at \assistant-simple\node_modules\express\lib\router\index.js:281:22
at Function.process_params (\assistant-simple\node_modules\express\lib\router\index.js:335:12)
at next (\assistant-simple\node_modules\express\lib\router\index.js:275:10)

@stevenpkg
Copy link

@germanattanasio have you any thoughts why the session Id is failing?

@ElinShek
Copy link

ElinShek commented Feb 11, 2019

I'm having the same issue here. It works with the username and password of the old Assistant, but it does not work with the new Assistant service credentials ASSISTANT_IAM_APIKEY, ASSISTANT_URL=https://gateway.watsonplatform.net/assistant/api/, and ASSISTANT_ID that I provide.

I tested the following code and it works. Not sure where it is messing up in the app.js?

var watson = require('watson-developer-cloud');

var service = new watson.AssistantV2({
  version: '2018-11-08',
  iam_apikey: '<iam_apikey>',
  url: 'https://gateway.watsonplatform.net/assistant/api/'
});

service.createSession({
  assistant_id: '<assistant_id>',
}, function(err, response) {
  if (err) {
    console.error(err);
  } else{
    console.log(JSON.stringify(response, null, 2));
  }
});

getting the same thing as dandresv hitting /api/session

@stevenpkg
Copy link

stevenpkg commented Feb 11, 2019

Not sure ATM, will try and test some more with different account myself to see if I can replicate this issue. @ElinShek there is no need to put the iam_apikey and url in the V2 constructor, just have them in your .env file, make sure you only specify one type of login, username or iam

@ElinShek
Copy link

My simple app is working now. You have to make sure that you don't have the old service credentials in your environment still (i.e. ASSISTANT_USERNAME, ASSISTANT_PASSWORD, etc.) I used a new terminal and everything works with the IAM api key. FYI...

@ToniHuovinen
Copy link

My simple app is working now. You have to make sure that you don't have the old service credentials in your environment still (i.e. ASSISTANT_USERNAME, ASSISTANT_PASSWORD, etc.) I used a new terminal and everything works with the IAM api key. FYI...

Could you open this little bit. I am having same issues and I can't seem to be able to solve it. Also I am bit confused on where I could find the needed information, I feel I have taken the wrong ones

@ElinShek
Copy link

ASSISTANT_IAM_APIKEY is used starting with Assistant version 2. If your Assistant is created during version 1 then you have to use the username and password. If you go to your dashboard in Bluemix, click on your Assistant instance, on the Manage page where there is a Launch tool button... there should be an API Key and a URL. API Key = ASSISTANT_IAM_APIKEY and URL = ASSISTANT_URL.

You also have to make sure you have an Assistant in place with a skill. Assuming you have a skill (aka workspace back then) all created. Go to Assistants tab and Create new, name the assistant with whatever you want and click on Create. Click on the newly created Assistant and add the skill to the assistant.
image
Then, go to View API Details. In here you will find your Assistant ID which is your ASSISTANT_ID in the .env file.

This combination worked for me...ASSISTANT_IAM_APIKEY, ASSISTANT_URL, and ASSISTANT_ID in the .env file and sourced in the environment where I do npm start. Comment out all the other variables in .env. Make sure you comment out before sourcing the .env file. Otherwise it will not work as it tries to use the other ones. So to be absolutely sure, in your terminal echo $ASSISTANT_USERNAME and the other variable that are commented out in your .env and make sure it doesn't exist.

Hope this helps.

@ToniHuovinen
Copy link

Thank you very much! I got it working. I had ASSISTANT_URL incorrect.

@huesoamz
Copy link

huesoamz commented Jul 3, 2019

That it's the time of the "session"? how can configure that and the message?

Because a lot of times the demo show this (sounds like that session expired or something like that)

image

NotFound: session id e6066d98-a3d1-489d-b91d-e44cdb616539 for agent instance 1ed2ee6d-9f40-4c62-bd2a-089081cef547

Full response:

https://jsonblob.com/41766720-9dde-11e9-af06-038bec3250b4

@Oliver-I
Copy link
Contributor

Oliver-I commented Jul 4, 2019

@huesoamz That's correct, the error message will appear when the app can't connect to the assistant (when it times out after approx 5 mins, or you lose connection to the assistant). By refreshing the page the app creates a new session ID and can interact with the assistant.

@huesoamz
Copy link

huesoamz commented Jul 4, 2019

@huesoamz That's correct, the error message will appear when the app can't connect to the assistant (when it times out after approx 5 mins, or you lose connection to the assistant). By refreshing the page the app creates a new session ID and can interact with the assistant.

And how can increase that time?, 5 minutes its not enough and how customize the message for that error? (portuguese...spanish) I had more than 5 bots for migrate to this version (assistantv2 from conversation) and need to change that because are bots on produtions enviroments.
Could you please help me?
Thanks in advance,

@Oliver-I
Copy link
Contributor

Oliver-I commented Jul 4, 2019

@huesoamz The timeout limit can be found in the assistant settings. Go to your Assistant and click on the Settings option (found on the right-hand side of the screen).

image

Then select the Inactivity Timeout option from the left-hand menu. It will show you the timeout limit applied to your assistant. Please note different plans have different maximum limits - for more information go to https://cloud.ibm.com/docs/services/assistant?topic=assistant-assistant-settings#assistant-settings.

image

@huesoamz
Copy link

huesoamz commented Jul 4, 2019

Oliver very thanks for your support but the URL that you provide doenst work, I general we use "standard" plan, but the maximum in that cases its only 5 minutes..

EDIT: I confirmed that it's the language that your browser is set to. I changed my browser language to English and works the page, so I can see the plans:

image

And the other question is...why if my Assistant its on spanish I receive a message on english? how can customize this message "I'm having trouble connecting to the server, please refresh the page "

EDIT2: I found the text on this file:
https://github.com/watson-developer-cloud/assistant-simple/blob/c9278bb4f209fbb81fd799c6636c4bf2bad29b6a/public/js/api.js

I think that would be better if we set that text on app.js (in server) not in "public/js" like:
image

and on api.js something like:

image

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

No branches or pull requests

8 participants