I am a newbie and trying to integrate my app with slack. I am using wss url that we get in the response from rtm.start and tried establishing connection through simple JS code and in response to it I get following error
{isTrusted: true, data: "{"type":"error","error":{"msg":"Cannot create connection","code":3,"source":"gs-bom-bcfd"}}", origin: "wss://cerberus-xxxx.lb.slack-msgs.com", lastEventId: "", source: null, …}
when I use the wss url from response in tester tab of the following link https://api.slack.com/methods/rtm.start/test it works fine and I start getting events.
js code that I used is as below
var ws = new WebSocket("wss URL");
ws.onopen = function(event) {
console.log("WebSocket is open now.");
};
ws.onmessage = function(event) {
console.log("WebSocket message received:", event);
};
Note: I have been using same authentication token from both the places, So no difference in application scope.
can someone guide me on this what's wrong with this? Thanks in advance.
I found the reason for this issue that might help others too if they are stuck with any similar situation.
I am using the slack package from npm for integration to my react app and in the slack package in node_modules, it already is creating a socket connection in rtm.client-browser file so when I try to create connection from my code it gives error as already a connection using same wss url has been requested by slack.
do check networks tab for any duplicate connection requests.