-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
fix(realtime): allow to use websocket without sticky sessions #5688
Conversation
DEV-1179 [BUG] "Sticky Sessions" should not be required with websockets
Describe the bug To Reproduce Try to use the webchat. Connection does not establish during the "handshake" Expected behavior Screenshots Environment (please complete the following information): Additional context |
@@ -95,8 +95,6 @@ | |||
"@types/redlock": "^4.0.0", | |||
"@types/seedrandom": "^2.4.28", | |||
"@types/semver": "^7.3.8", | |||
"@types/socket.io": "^2.1.2", | |||
"@types/socket.io-client": "^1.4.36", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those typings are not required anymore as they come with both libraries
path: `${process.ROOT_PATH}/socket.io`, | ||
origins: '*:*', | ||
serveClient: false | ||
cors: { origin: '*' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we only allow externalURL/localURL as the origin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, i'm not sure for that point. Maybe we should use the same cors property we have for httpServer in botpress config? We'd need to highlight the change in the release notes since it may be breaking
Updating this library means we have a lot of scenarios to test.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
path: `${process.ROOT_PATH}/socket.io`, | ||
origins: '*:*', | ||
serveClient: false | ||
cors: { origin: '*' }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question, i'm not sure for that point. Maybe we should use the same cors property we have for httpServer in botpress config? We'd need to highlight the change in the release notes since it may be breaking
Weird, because it should be compatible with IE9+ (see: https://socket.io/docs/v4/client-installation/#browser-support) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
@laurentlp does this fix this issue botpress/v12#1541? |
@davidvitora No, you still need to use the workaround you suggested. I think this issue will be properly fixed once Messaging will provide the new version of the webchat. |
Description
This PR upgrades the socket.io library to its latest version and Socket V4.
I followed those two migration guides, one after the other:
It also re-implements the socket.io-jwt library that was provided by the auth0 community but has since been deprecated (see: https://community.auth0.com/t/community-repo-deprecations-september-2021-eol/60380).
And finally, it modifies the realtime-service
getVisitorIdFromSocketId
to allow fetching the rooms of sockets from other nodes (this is required since the channel-web sends socket and HTTP requests).It is now possible to only use
'websocket'
as the only transport mode for socket connection and not configure sticky sessions.Related to: botpress/studio#203
Fixes botpress/v12#1177
Closes DEV-1179
Also closes this PR #5156
Type of change
Please delete options that are not relevant.
How has this been tested?
Start multiple instances of Botpress and use Nginx to serve all those instances. Make sure to use Postgres and enable Redis.
yarn start bench --url http://localhost:3000 --botId=<BOT_ID> --web
)Single node, with only websocket (and only longpolling)
Maybe I am missing some tests?
Checklist: