We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.
Hi Jami
You could have used generic event also. Is there specific reason you went with creating websocket?
Have you never tried something just to have fun and experiment?
Haha...I have a similar implementation requirement so I was exploring what are the ways we can achieve and came to know about your article. I guess I will implement generic event for now and on later stage use web-socket to scale it.
https://media4.giphy.com/me...
Hi I am not able to connect to heroku url using lwc.I am getting an error related to CSP. Can you suggest how to resolve?
You need to add it as a trusted site in your CPS settings. That can either be done manually from your orgs Salesforce settings, or, deploy cspTrustedSites metadata with your urls. Examples: https://github.com/jamigibb...
Great Article to start on to develop a real time chat application in Salesforce.
Heroku Dyno's restart automatically, and the socket may reset. Did you face that issue real time?
One more question is to dynamically assign different ports to different orgs and people of one org can connect to same port and assign them dynamically based on some config for each organisation. Is that a possible use case? Please correct me if I am wrong.
The dyno restarts on the free tier and yes, that would be a problem for maintaining a websocket connection. I wouldn't use a free dyno with production code.
I'm not really sure what you're wanting to accomplish with assigning different ports. Are you talking about allowing users across different organizations to chat through the same component/websocket?
Allowing users from same organisation to the same port. People from different organisations will have different port to chat with.
Nice Article. Thank you. Just a query- how is authentication taken care of during Websocket connection.
Good question. I would probably integrate two levels for authentication. The first would be checking for an authorized origin header. This way you could difference between connections from different hosts. I think if someone really wanted to work around this, a non-browser client could spoof the host to whatever they want though. So the second layer would be to integrate some kind of authentication token or key. If there isn't a Salesforce specific way to do it, I might look at integrating a JSON web token (JWT) between the client and Node server: https://jwt.io/
Connection through socket io library works like a charm, Do you happen to know how we can use websocket instead socket io libraries.
Thank you