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

Web Chat shows retry but message is really sent to bot #465

Closed
alokraj68 opened this issue May 17, 2017 · 36 comments
Closed

Web Chat shows retry but message is really sent to bot #465

alokraj68 opened this issue May 17, 2017 · 36 comments
Labels
question Further information is requested. Stack Overflow candidate
Milestone

Comments

@alokraj68
Copy link

Hi,
The web chat is showing could not send please retry, but the message is really sent to bot. what really goes wrong is that user will press retry and the bot will get the message every time the retry is pressed.

@forceamp
Copy link

I am having the same issue. My bot is doing image analysis so it could take up to 10 seconds to respond.

@alokraj68
Copy link
Author

alokraj68 commented May 20, 2017 via email

@ohmusama
Copy link

Other channels allow 15 seconds to respond. It would be nice if webchat abided this timeout too.

@billba
Copy link
Member

billba commented May 24, 2017

How quickly is "retry" shown? Which SDK are you using?

DirectLineJS (which is what WebChat uses) actually observes a 20 second timeout. If it's showing "retry" before then, it's because of a different problem.

@billba
Copy link
Member

billba commented May 24, 2017

@alokraj68 I don't quite understand your scenario but it sounds like a different bug. Please open a new issue for it.

@akasranjan005
Copy link

I am also facing the same issue, the bot responds with "couldn't send retry" but actually the conversation proceeds. How can i fix this?

@ohmusama
Copy link

ohmusama commented Jun 27, 2017 via email

@billba
Copy link
Member

billba commented Jun 27, 2017

I would still like to know more about this problem. WebChat/DirectLineJS has a 20 second timeout. Are you all seeing faster fails than that? If so it's (probably) not on the client side. In your response please say which SDK you are using (.net or node).

@ohmusama
Copy link

ohmusama commented Jun 27, 2017 via email

@alokraj68
Copy link
Author

Hi guys,
Am also receiving a similar error in telemetry. am using .net SDK.
This error started to creep in recently. we are not able to identify what causes this error.

@akasranjan005
Copy link

I am using rest api on python, maybe the case is of timeout but how can i handle it if the processing work takes more than 20 sec?

@alokraj68
Copy link
Author

but in our case, the processing is not taking that long when we do the testing,

@danmarshall danmarshall added the bug Indicates an unexpected problem or an unintended behavior. label Sep 21, 2017
@frnk01
Copy link

frnk01 commented Sep 26, 2017

I'm having the same issue with the built in iframe.
Facing two errors:

  • Couldnt send
  • My bot code is having issues

@danmarshall
Copy link
Contributor

Hello everyone, here's a couple of tips for these kinds of errors.

  • Make sure you log all errors in your bot. If your bot returns an HTTP 500, Direct Line will then pass that as a 502, which will appear as a failure to Web Chat. You will need to know why your bot had the 500 error.
  • If you are using the .NET SDK, and you are logging errors, and your error is "Authorization for Microsoft App ID failed with status code Forbidden", then you may need to add a call to MicrosoftAppCredentials.TrustServiceUrl(serviceUrl) - see BotBuilder solutions for similar issues.

@ashish-harsora
Copy link

Hello every once i am working on microsoft bot, direct line,
and deployed on my personal server on IIS,
If i test it threw emulator it is working fine, but if i test it threw I Frame in my website it si giving me 502 Bad Gateway error

POST https://webchat.botframework.com/v3/directline/conversations/HyZVX4cBPGh115QwKfStKj/activities 502 (Bad Gateway)

this is in channel page:
There was an error sending this message to your bot: HTTP status code InternalServerError

compulim pushed a commit to compulim/BotFramework-WebChat that referenced this issue Jul 14, 2018
…ove-depricated-fields

#22733 - removed fields designed for just a single bot
@andrewchungxam
Copy link

Is there ways to customize when the retry message comes up? Some OCR processes take more time than the default 20 seconds.

@sgellock sgellock added 4.3 p2 Nice to have labels Oct 30, 2018
@compulim compulim added this to the v4.3 milestone Oct 30, 2018
@corinagum
Copy link
Contributor

corinagum commented Nov 28, 2018

Investigate if fixed in v4. If not, mark as P3 or P4 for 4.4

@compulim compulim modified the milestone: v4.3 Nov 28, 2018
@compulim compulim added the size-s 1 days or less label Dec 8, 2018
@ECocca
Copy link

ECocca commented Feb 27, 2019

I tried unsuccessfully the workaround.
test

@EricDahlvang
Copy link
Member

EricDahlvang commented Feb 27, 2019

This is not an issue with WebChat. There are a number of things that can cause a 'couldn't send retry'. Generally, not returning HttpStatusCode.OK from the bot within 15 seconds is the primary cause. Returning some other status code (or not returning any status code), a long running process within the bot, a fatal exception within the bot, cold start issues (solved with 'Always On' in Azure), etc. There is not a single resolution for this, and it is definitely not a WebChat issue.

If 'couldn't send retry' is displayed when in fact the message did arrive, it is an indication there is a problem within the bot code.

@adalfa
Copy link

adalfa commented Feb 28, 2019

@EricDahlvang : the issue stated is that the 'couldn't send retry' is raised even if the message i received by the bot. If you try with a long running operation (even a Thread.Sleep) you always receive 'couldn't send retry', but the message is received by the bot code. What we do not understand from @compulim is if the typing Activity sent every 3 sec should get rid of 'couldn't send retry' or is just an usability/estetic workaround for the user. We are able to send the typing activity during long running operations, but we alway get the retry even if we process the original message back to the user. thanks

@EricDahlvang
Copy link
Member

EricDahlvang commented Mar 1, 2019

@adalfa Sending a typing activity will not result in also responding with HttpStatusCode.Ok within the required 15 seconds.

The connector service will hold the connection open for 15 seconds (even if the message has been received and is being processed bot side). It holds the connection open until it receives an HttpStatusCode.Ok (200). If it does not receive the 200, it assumes the message was not successfully sent and this propagates back to the WebChat control, showing as 'couldn't send retry'. This is how the protocol is setup. This is not related to WebChat, but rather the behavior of the connector services communication with the bot. If your bot is not responding with a 200 within 15 seconds, it is a bot issue.

Edit: see here for more discussion around this microsoft/botbuilder-dotnet#598

@adalfa
Copy link

adalfa commented Mar 2, 2019

@EricDahlvang thanks for the response. I understand that we are talking of a sort of violation from the bot code to the connector. what I fail to understand is @compulim suggestion

And since the bot replied, Web Chat will not receive 502 due to gateway timeout.

your statement make me think that this is not a viable resolution from the bot side so I ask you what is expected in 4.4 version: an update to the documentation or any change to the webchat code or anything else?
you suggest that any further discussion of the matter should be continue on the issue you referenced?
many thanks again

@EricDahlvang
Copy link
Member

I'm not sure why @compulim suggested that. He is out today.

It is fine to continue the discussion here, I'm just trying to clear up any confusion about why developers see 'couldn't send retry' in WebChat when in fact the message was received by the bot. Future developers who come across this issue should be aware of how the underlying protocol works.

@corinagum corinagum added question Further information is requested. Stack Overflow candidate and removed 4.4 bug Indicates an unexpected problem or an unintended behavior. community-help-wanted This is a good issue for a contributor to take on and submit a solution p2 Nice to have size-s 1 days or less front-burner labels Mar 21, 2019
@corinagum
Copy link
Contributor

I'm leaving this issue open since it appears to be a common question Web Chat users have. However there is no action item for the Web Chat team. If you would like to pursue more information or track the potential change in protocol, please see microsoft/botbuilder-dotnet#598

@compulim
Copy link
Contributor

compulim commented May 3, 2019

Sorry didn't response to this sooner.

@adalfa if the bot is expected to take > 15 seconds to work on one thing, I believe the best practice is the bot respond to it first (by sending typing indicator, or just do nothing). Then, the bot should use proactive messaging mechanism to send result back later.

That's why I was saying, "the bot replied, Web Chat will not receive 502".

What do you think?

@corinagum corinagum mentioned this issue May 3, 2019
37 tasks
@corinagum corinagum changed the title Web Chat shows retry but message is really send to bot Web Chat shows retry but message is really sent to bot Jun 23, 2019
@Kaiqb Kaiqb added the Customer label Jul 23, 2019
@shanugit
Copy link

shanugit commented Jun 3, 2020

Hi @compulim,

The issue is there even after typing indicator is working.

send failed after 15 sec

"botbuilder-ai": "^4.9.0",
"botbuilder-azure": "^4.6.2",
"botbuilder-dialogs": "^4.8.0",
"botbuilder-solutions": "^4.4.9",

Botframework v4, Typescript. Webchat

How to fix this? Please let me know if any more information is required.

@grimz11
Copy link

grimz11 commented Aug 4, 2020

Botframework-webchat 4.9.1

I have a similar problem. I think this was a problem with the library itself because I tried it on Bot emulator and it works just fine. But I just found out why it does happen for instance if we have a similar case here. This problem will happen if you're calling the action type DIRECT_LINE/POST_ACTIVITY_FULFILLED like this way.

  if(action.type === "DIRECT_LINE/POST_ACTIVITY_FULFILLED" &&  action.payload!.activity!.entities!.length > 0){
  //code here...
 }

The non-null assertion operator just won't work instead when I changed it to operational chaining the problem was solve.

  if(action.type === "DIRECT_LINE/POST_ACTIVITY_FULFILLED" &&  action.payload?.activity?.entities?.length > 0){
  //code here...
 }

Or the longer way.

  if(action.type === "DIRECT_LINE/POST_ACTIVITY_FULFILLED" &&  action.payload && action.payload.activity && action.payload.activity.entities && action.payload.activity.entities.length > 0){
  //code here...
 }

@compulim do you have any idea why the already sent message got called again when there's a new request?

@compulim
Copy link
Contributor

compulim commented Aug 4, 2020

Emulator is using Web Chat UI without much customization. 😅

However, Emulator emulates Azure Bot Services (i.e. the Direct Line protocol), thus, the actual activity being sent to the bot could be slightly different, due to the emulation layer.

Direct Line protocol diagram can be found here, https://github.com/microsoft/BotFramework-WebChat/blob/master/docs/media/direct-line-sequence-diagram.png.

Web Chat consider a message is being sent successfully, when the bot acknowledged it (a.k.a. read receipt).

To consider the message is being successfully sent, technically, it means 2 bottommost packets (blue and orange), need to be received on the Web Chat side in a positive manner.

If the bot crashed in the midway, the purple packet (from bot to ABS) will not be sent. Thus, it will lead to the orange packet missing.

From your code, can you check if the bot crashed? Also, please look at your browser's network tab (or Fiddler) to check if the traffic is correctly received on one end.

image

@shanugit
Copy link

shanugit commented Aug 4, 2020

Hi @compulim,

The screenshot i have given, it was from my web page. In the emulator i was not getting the issue.

Now i did some UI modification for the bot and the issue is solved automatically.

Warm Regards,
Suman

@grimz11
Copy link

grimz11 commented Aug 4, 2020

@compulim, Oh thank you for that explanation.
This is what happens if I use the first condition.
image

Everything seems normal in my network tab.
image

@compulim
Copy link
Contributor

compulim commented Aug 4, 2020

What you are showing is the orange arrow packet.

Can you also check the blue arrow packet?

image

@grimz11
Copy link

grimz11 commented Aug 4, 2020

@compulim, Yea my bad.
Here
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested. Stack Overflow candidate
Projects
None yet
Development

No branches or pull requests