socket.io issue using sails.js

2019-08-09 15:39发布

I am trying to use socket.io with sails js. I understood that it was pretty straighforward and that sails provided an available socket.io structure out of the box. Howeve When I try to connect to my sails server from a distant client using

io.connect(http://localhost:1337)

It makes my server crash with the message:

/node_modules/express/node_modules/connect/lib/utils.js:216 return 0 == str.indexOf('s:') ^ TypeError: Cannot call method 'indexOf' of undefined

I am probably missing something but I don't understand what.... Any clue about this?

Thanks !

2条回答
趁早两清
2楼-- · 2019-08-09 16:14

ahem... Did you had a look @ the doc : http://sailsjs.org/#!documentation/sockets this is quite self explanatory, but if you need any help

查看更多
爱情/是我丢掉的垃圾
3楼-- · 2019-08-09 16:20

Looks like you're missing some quotes in your io.connect() call, but I can't imagine that your client app wouldn't throw a syntax error if your code really was written like that. Verify you've got:

io.connect('http://localhost:1337');
查看更多
登录 后发表回答