microsoft / microsoft/BotFramework-WebChat
Error during WebSocket handshake: Unexpected response code: 403
@compulim is already working on this.
Since Oct 11, 2021.
- Dominant language
- HTML
- Stars
- 1.8k
- Forks
- 1.6k
- Avg merge
- 22h 58m
- Merged PRs (30d)
- 2
Description
Using directLine or Webchat with my bot
After 5 minutes of using the bot i get a Websocket error.
authentication.service.ts:85 WebSocket connection to 'wss://directline.botframework.com/v3/directline/conversations/49zS5PwGN3TFWlfLAgKoKz-us/stream?watermark=-&t=ew0KICAiYWxnIjogIlJTMjU2IiwNCiAgImtpZCI6ICJ2cG4yYXhuRjFSU3NHUXg5aXd0WGEwZTNjRWciLA0KICAieDV0IjogInZwbjJheG5GMVJTc0dReDlpd3RYYTBlM2NFZyIsDQogICJ0eXAiOiAiSldUIg0KfQ.ew0KICAiYm90IjogIlBNRS1Cb3QtRCIsDQogICJzaXRlIjogIjl4TEU5aTVncEx3IiwNCiAgImNvbnYiOiAiNDl6UzVQd0dOM1RGV2xmTEFnS29Lei11cyIsDQogICJuYmYiOiAxNjMzNjk1NDAwLA0KICAiZXhwIjogMTYzMzY5NTQ2MCwNCiAgImlzcyI6ICJodHRwczovL2RpcmVjdGxpbmUuYm90ZnJhbWV3b3JrLmNvbS8iLA0KICAiYXVkIjogImh0dHBzOi8vZGlyZWN0bGluZS5ib3RmcmFtZXdvcmsuY29tLyINCn0.ScI-lSR2R1mQ3yUda7sYYJCU--hy6m0yLAgWgF0sEQ80-o6r90tvkBIJ8olR4mPJZxBbRTsnUnREXr-Bc61LM6OsjDGqa0kkJsA8jlF5Sw00wBrXND2PUGsWcauBppd6FRHmp5qhrivQQ9IpgnqRevkG8rVyIKUOi_-lbQz1AwWWHxxbpqfrRWKFvjyZplhDDL81i7dWYXQZRQn24LyWRgRVppdQcJHIFP5u5Zhcb37rp-6ElO7cRJULE6DCx73lg1rHjpeBzVDPKzAbSZWu8jt628qgIGYNVPRHqiCS05NXnGBkO-RJY0dwvUZ1nEVFTWsU79MEm6QTS4mVyZ9dHw' failed: Error during WebSocket handshake: Unexpected response code: 403
If I let the chat window open everything is fine. When i close the chat windows and then reconnect to the conversation the websocket error appear and the history isn't comming back. The chat still work but if i close it again the history is not saved anymore to the conversation.
I used postman to lisen to the websocket stream and i can see everything pass. When I try to connect to a stream after 5 minutes(after the websocket error), i got this message
Error: Unexpected server response: 403
Handshake Details
Request URL: https://directline.botframework.com/v3/directline/conversations/1xmoTM750ySKSoi8JvxNMV-6/stream?watermark=-&t=ew0KICAiYWxnIjogIlJTMjU2IiwNCiAgImtpZCI6ICJ2cG4yYXhuRjFSU3NHUXg5aXd0WGEwZTNjRWciLA0KICAieDV0IjogInZwbjJheG5GMVJTc0dReDlpd3RYYTBlM2NFZyIsDQogICJ0eXAiOiAiSldUIg0KfQ.ew0KICAiYm90IjogIlBNRS1Cb3QtRCIsDQogICJzaXRlIjogIjl4TEU5aTVncEx3IiwNCiAgImNvbnYiOiAiMXhtb1RNNzUweVNLU29pOEp2eE5NVi02IiwNCiAgIm5iZiI6IDE2MzMzNTk5OTUsDQogICJleHAiOiAxNjMzMzYwMDU1LA0KICAiaXNzIjogImh0dHBzOi8vZGlyZWN0bGluZS5ib3RmcmFtZXdvcmsuY29tLyIsDQogICJhdWQiOiAiaHR0cHM6Ly9kaXJlY3RsaW5lLmJvdGZyYW1ld29yay5jb20vIg0KfQ.tNDu_5s4FhPHxhKNjsaXB6t5OVHZ1z6jMto9olBXIVmt4myAP_Gw--RsS3B6cuR5roL9n5fPPo_gUVWye8SsYG9Y28yKheVAnFto6XlD2e5Ew-llJr4fXmpQW9sXDcO_lp4oLsWvWogj33xH7ua1smP6oEZ9ZvfKl1XrTW2E0fpplPKzZPJsal3iBKVseRIRisPIQqcZSD-Dw9dmJWfcy-MWW1j78pumDCk-p4p6Dpts4yGH-v_oguaVcB-1-6bnSuwxljIbcFGtHc6jRE5acriCrCWFvcER99BoHHxvTHOfHBDmBFrjLPx2nsxV7hOaLpAsx8N4p8XkRaIGM_owDw
Request Method: GET
Status Code: 403 Forbidden
Request Headers
Sec-WebSocket-Version: 13
Sec-WebSocket-Key: 07TEu7JXBDayOkiMgA/l8g==
Connection: Upgrade
Upgrade: websocket
Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits
Host: directline.botframework.com
Response Headers
Cache-Control: no-cache
Pragma: no-cache
Content-Length: 88
Content-Type: application/json; charset=utf-8
Expires: -1
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Strict-Transport-Security: max-age=31536000
ARR-Disable-Session-Affinity: true
Date: Mon, 08 Oct 2021 15:13:14 GMT
I tried to make a loop to send a message each 60 seconds on my website with a secondary direct line connection to the same credentials. I wanted to find out if it's en idle problem and it's not.
this.mySubscription= interval(environment.webSocketPingDelay).subscribe((x =>{
let directLine = window.WebChat.createDirectLine({
token: this.storageService.token,
webSocket: environment.payload.webSocket,
conversationId: this.storageService.conversationId,
streamUrl: this.storageService.streamUrl
});
directLine.postActivity({
from: { id: Authentication.user, name: "USER_NAME" },
name: "keep_alive",
type: "message",
Text: "Keep"
}).subscribe();
}));
Since the web socket address indicate that the websocket is hosted on azure. "wss://directline.botframework.com/v3/directline/conversations/***"
On my azure channel i see no option to configure websocket.
On my webapi i used this configuration in my startup.cs
var webSocketOptions = new WebSocketOptions()
{
KeepAliveInterval = TimeSpan.FromSeconds(120),
};
app.UseWebSockets(webSocketOptions);
How can i configure it to last more than 5 minutes ?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.