view raw
Euregan Euregan - 11 months ago 125
Node.js Question

404 on websocket connection to Slack's RTM API

I am having the weirdest error when trying to connect to the RTM API from Slack.

I am implementing a simple bot in node, and I am using to handle the web socket connection. However, it always throws the error

{ [Error: xhr poll error] type: 'TransportError', description: 404 }

My code looks like this:

requester.GET({target: ''}, [{key: 'token', value: config.token}], function(data) {
data = JSON.parse(data)
if (data.ok) {
let socket = require('')(data.url)
socket.on('connect', function(){})
socket.on('event', function(data){})
socket.on('disconnect', function(){})
socket.on('connect_error', function(err) {
} else {

is a file I wrote myself, handling simple HTTP calls, like GET here.
The thing is, I am using the URL returned by Slack the moment I get it, so why am I getting a code 404 ? What am I doing wrong ?


I don't think does what you want... I believe it's a client to talk to a server that's using (which Slack isn't). I believe is trying to make an HTTP request to the URL. You should be specifically using a WebSocket client. Maybe try the ws library?