microsoft / botframework-sdk

Bot Framework provides the most comprehensive experience for building conversation applications.
MIT License
7.5k stars 2.44k forks source link

Facebook: Retry if response status is 400 (Bad request) #1621

Closed onchainguy-btc closed 7 years ago

onchainguy-btc commented 7 years ago

Got the following problem when sending a message to facebook:

2016-11-09T14:51:19.740681+00:00 app[web.1]: Error: Request to 'https://facebook.botframework.com/v3/conversations/123456-abc/activities' failed: [400] Bad Request
2016-11-09T14:51:19.740695+00:00 app[web.1]:     at Request._callback (/app/node_modules/botbuilder/lib/bots/ChatConnector.js:413:46)
2016-11-09T14:51:19.740697+00:00 app[web.1]:     at Request.self.callback (/app/node_modules/request/request.js:186:22)
2016-11-09T14:51:19.740698+00:00 app[web.1]:     at emitTwo (events.js:106:13)
2016-11-09T14:51:19.740698+00:00 app[web.1]:     at Request.emit (events.js:191:7)
2016-11-09T14:51:19.740699+00:00 app[web.1]:     at Request.<anonymous> (/app/node_modules/request/request.js:1081:10)
2016-11-09T14:51:19.740699+00:00 app[web.1]:     at emitOne (events.js:96:13)
2016-11-09T14:51:19.740700+00:00 app[web.1]:     at Request.emit (events.js:188:7)
2016-11-09T14:51:19.740700+00:00 app[web.1]:     at IncomingMessage.<anonymous> (/app/node_modules/request/request.js:1001:12)
2016-11-09T14:51:19.740701+00:00 app[web.1]:     at IncomingMessage.g (events.js:292:16)
2016-11-09T14:51:19.740701+00:00 app[web.1]:     at emitNone (events.js:91:20)
2016-11-09T14:51:19.740702+00:00 app[web.1]:     at IncomingMessage.emit (events.js:185:7)

When I take a look into the error message on https://dev.botframework.com/ I can see that the bad request is caused by:

{"error":{"message":"(#100) Upload attachment failure","type":"OAuthException","code":100,"error_subcode":2018047,"fbtrace_id":"E5YbWA\/URA+"}}

It simply seemed to be a temporary issue on Facebook because it worked again a few minutes afterwards. Is there any chance to automatically retry sending a message? Or is there at least the option to give the user feedback that there is something wrong with the but providing something like a "try again" button?

lyzs90 commented 7 years ago

Same here, i am occasionally getting this error when sending a carousel to facebook:

2016-11-27T10:40:53.900414+00:00 app[web.1]: Error: Request to 'https://facebook.botframew
ork.com/v3/conversations/1173203116080823-636060139906625/activities/mid.1480243250303%3Ae
1d66fe656' failed: [400] Bad Request
2016-11-27T10:40:53.900419+00:00 app[web.1]:     at Request._callback (/app/node_modules/b
otbuilder/lib/bots/ChatConnector.js:413:46)
2016-11-27T10:40:53.900425+00:00 app[web.1]:     at Request.emit (events.js:188:7)
2016-11-27T10:40:53.900421+00:00 app[web.1]:     at Request.self.callback (/app/node_modul
es/request/request.js:186:22)
2016-11-27T10:40:53.900422+00:00 app[web.1]:     at emitTwo (events.js:106:13)
2016-11-27T10:40:53.900427+00:00 app[web.1]:     at emitNone (events.js:91:20)
2016-11-27T10:40:53.900422+00:00 app[web.1]:     at Request.emit (events.js:191:7)
2016-11-27T10:40:53.900423+00:00 app[web.1]:     at Request.<anonymous> (/app/node_modules
/request/request.js:1081:10)
2016-11-27T10:40:53.900424+00:00 app[web.1]:     at emitOne (events.js:96:13)
2016-11-27T10:40:53.900426+00:00 app[web.1]:     at IncomingMessage.<anonymous> (/app/node
_modules/request/request.js:1001:12)
2016-11-27T10:40:53.900426+00:00 app[web.1]:     at IncomingMessage.g (events.js:291:16)

In the botframework control panel, the error i'm getting is:

{"error":{"message":"(#100) [elements][0][image_url] should represent a valid URL","type":"OAuthException","code":100,"fbtrace_id":"HlzK5LWpyRN"}}

The same bot, on Telegram is also giving these errors:

Error: Request to 'https://telegram.botframework.com/v3/conversations/216050977/activities/6H0zDLwg16z' failed: [500] Internal Server Error
    at Request._callback (C:\Users\admin\Desktop\DSProjects\Coconut\node_modules\botbuilder\lib\bots\ChatConnector.js:413:46)
    at Request.self.callback (C:\Users\admin\Desktop\DSProjects\Coconut\node_modules\request\request.js:186:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (C:\Users\admin\Desktop\DSProjects\Coconut\node_modules\request\request.js:1081:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (C:\Users\admin\Desktop\DSProjects\Coconut\node_modules\request\request.js:1001:12)
    at IncomingMessage.g (events.js:292:16)
    at emitNone (events.js:91:20)
    at IncomingMessage.emit (events.js:185:7)
    at endReadableNT (_stream_readable.js:974:12)
    at _combinedTickCallback (internal/process/next_tick.js:74:11)
    at process._tickDomainCallback (internal/process/next_tick.js:122:9)

I did some logging and everything is well until the part where you session.send the carousel. the carousel simply doesnt appear. then the bot continues with the rest of the dialogs

chrimc62 commented 7 years ago

@Stevenic or @maxpert can you comment?

lyzs90 commented 7 years ago

I managed to solve my Facebook issue! It was because my data had invalid image urls. Still getting issues for Telegram though, and strangely enough there are no errors on the botframework site.

Stevenic commented 7 years ago

Added eric to answer telegram questions...

We don't currently have automatic retry logic although I've brought that up as well.

eanders-ms commented 7 years ago

@lyzs90 Sorry so late to the conversation! Are you still seeing this issue in Telegram?

lyzs90 commented 7 years ago

@eanders-MS sorry i am not able to repro this on Telegram; my bot has moved on also since then

johe123qwe commented 8 months ago

[ "error" => [ "message" => "(#100) Upload attachment failure.", "type" => "OAuthException", "code" => 100, "error_subcode" => 2018047, "fbtrace_id" => "Bx3s3xd_MQ334bUXchs7kbW3", ], ]

I encountered the same problem when uploading pictures to Facebook, is there any solution? Thanks!