botframework-sdk icon indicating copy to clipboard operation
botframework-sdk copied to clipboard

[Question] Hosted Bot working with emulator but not with WebChat?

Open officialdharam opened this issue 9 years ago • 6 comments

System Information

  • SDK Language: Node.js
  • SDK Version: 3.9.0
  • Development Environment: Hosted on EC2

Bot Info

  • Bot name: hero
  • Bot handle: herotestnew
  • App ID: 9d9ad115-7855-4461-a9ea-dd34ac2575b8
  • Connected channels: WebChat

Issue Description

I create a simple bot and hosted it on EC2 with a https endpoint.
I registered the bot with the Microsoft Bot Developer Portal, the App ID is given above. My emulator installed on a local windows system is able to communicate with the bot directly.

However, when I tried testing using the Test button on the Channels page in the Developer Portal, it threw me the below errors.

image

Here are the Request Details:

Request URL:https://webchat.botframework.com/v3/directline/conversations/484ec49e02a34330b20ef5b3e6a032ba/activities Request Method:POST Status Code:502 Bad Gateway Remote Address:137.116.153.238:443 Referrer Policy:no-referrer-when-downgrade

Response Headers view source Access-Control-Allow-Origin:* Cache-Control:no-cache Content-Length:117 Content-Type:application/json; charset=utf-8 Date:Mon, 21 Aug 2017 21:53:43 GMT Expires:-1 Pragma:no-cache Server:Microsoft-IIS/8.0 Strict-Transport-Security:max-age=31536000 X-Powered-By:ASP.NET

Request Headers view source Accept:/ Accept-Encoding:gzip, deflate, br Accept-Language:en-GB,en-US;q=0.8,en;q=0.6,pl;q=0.4 Authorization:Bearer wdsfOLNGuO4.dAA.NAA4ADQAZQBjADQAOQBlADAAMgBhADMANAAzADMAMABiADIAMABlAGYANQBiADMAZQA2AGEAMAAzADIAYgBhAA.0ClHHcwa0wE.La3pPIwSvQI.VfzkwNPy20bGHzoA1wncKzJNBMGrtPjLpgra6sA3zE0 Connection:keep-alive Content-Length:332 Content-Type:application/json Cookie:UserId=IuP7kGoPPqS Host:webchat.botframework.com Origin:https://webchat.botframework.com No matter what, I am always getting this error.

Request Payload {type: "message", text: "Help", from: {id: "IuP7kGoPPqS", name: "You"}, locale: "en-US",…} channelData : {clientActivityId: "1503352408830.12112109312181119.0"} entities : [{type: "ClientCapabilities", requiresBotState: true, supportsTts: true, supportsListening: true}] from : {id: "IuP7kGoPPqS", name: "You"} locale : "en-US" text : "Help" textFormat : "plain" timestamp : "2017-08-21T21:53:42.940Z" type : "message"

Error { "error": { "code": "ServiceError", "message": "Failed to send activity: bot returned an error" } }

Code Example

I believe the bot code didn't cause any issue.

Steps to Reproduce the Issue

1. 2. 3.

Expected Behavior

The bot should work the same ways irrespective of the channel

Actual Results

officialdharam avatar Aug 21 '17 21:08 officialdharam

@officialdharam You are seeing this error because you are using a custom port number.

You need to use the default https port 443. Eg. https://HOSTNAME/api/messages

Also make sure to have a valid SSL certificate.

nwhitmont avatar Aug 22 '17 00:08 nwhitmont

@nwhitmont

Thanks for the response. So here is what I did.

  1. I have a self signed certificate, because I am just trying to build a sample bot for trying out the new version of the framework (I guess the self signed certificate will suffice)

  2. I started listening to port number 443 and configured the same in the portal (tried it with the port number appended to the URL and without it.

  3. None of them works, I get the same error.

  4. Also, I think that the port shouldn't be a restriction. I have worked with the previous version of the framework where I was using a random port.

Thanks in Advance for your help

officialdharam avatar Aug 22 '17 07:08 officialdharam

@nwhitmont correct me if I am wrong, but a self-signed certificate will not work if memory serves.

JasonSowers avatar Aug 22 '17 16:08 JasonSowers

@JasonSowers I guess you are right. This framework is getting more restrictive. Seriously asking a developer to use SSL certificate (that too not self signed).

I worked with the previous version a year back. It was amazing. Could you please suggest how should I go about it now. I have my bot hosted on AWS for now.

Thanks

officialdharam avatar Aug 22 '17 16:08 officialdharam

Update:

Here is the work around. Somehow, Azure gives a https endpoint by default and so I hosted my bot there. Everything works fine. However, this is a work around to my problem.

Here is the guide I followed to complete a nodejs setup on Azure:

https://docs.microsoft.com/en-us/azure/app-service-web/app-service-web-get-started-nodejs

After the setup, you can replace the index.js with your bot's index.js and update the package.json as well.

One point worth taking care: The deploy.cmd script wont install node_modules, if the package.json is already present in the wwwroot folder. So, I would suggest you to delete the package.json and other files.

@nwhitmont : If you wish you can close the issue, however, I think reducing the severity and keeping it open will help us in tracking a very important limitation of the framework. https and how to deploy it on ec2 without a valid domain name.

Thanks everyone.

officialdharam avatar Aug 22 '17 20:08 officialdharam

@officialdharam Self-signed certificate will not work. You need a valid SSL certificate recognized by Microsoft.

nwhitmont avatar Aug 25 '17 23:08 nwhitmont